Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including parser-utils with all npm packages installed. Try it out:

var parserUtils = require("parser-utils")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

parser-utils v0.3.1

Utilies for parser-cache and compatible parsers.

parser-utils NPM version

Utilies for parser-cache and compatible parsers.

Install

Install with npm:

npm i parser-utils --save-dev

Usage

var utils = require('parser-utils');

API

.fileKeys

  • returns {Array}: Array of keys.

Get the array of keys expected on normalized file objects.

.diffKeys

Get an array of keys that should not be on the root of a normalized file object.

  • obj {Object}: The object to inspect.
  • props {Array}: Array of properties to concat to the output.
  • returns {Array}: Array of keys

Example:

var utils = require('parser-utils');
var file = {a: 'a', b: 'b', path: 'a/b/c.md'};
console.log(utils.diffKeys(file));
//=> ['a', 'b']

.siftKeys

  • obj {Object}: The object to normalize.
  • props {Array}: Any additional properties to include.
  • returns {Object}: Normalized object.

Normalize the properties on the given obj.

.mergeData

  • obj {Object}: Object with data objects to merge.
  • locals {Object}: Optional object of data that should "win" over other data.
  • merge {Function}: Function to use for merging data.
  • returns {Object}: Object with a single data property.

Return an object composed only of data properties. If a locals object is supplied, properties in that object will override any properties on the data object. If a locals object is defined, and/or if the locals object has a nested locals property, both will be merged with the data property on the returned object.

.flattenObject

Merge nested properties into the root of the given object. Nested properties occur when, for instance, and options object - intended as locals, is also passed with an actual locals property.

  • obj {Object}: The object to flatten.
  • key {String}: The property to merge onto the root of the object.
  • merge {Function}: Function to use for merging data.
  • returns {Object}: Object with locals merged into the root.

Note that this will only merge properties one level deep.

Author

Jon Schlinkert

License

Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license


This file was generated by verb-cli on September 01, 2014.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free