utils

Members

(inner) debug

Source:

Module dependencies.

(inner) ignore

Source:

Ignored directories.

(inner) type

Source:
See:

Takes some variable and asks Object.prototype.toString() what it thinks it
is.

Example
type({}) // 'object'
type([]) // 'array'
type(1) // 'number'
type(false) // 'boolean'
type(Infinity) // 'number'
type(null) // 'null'
type(new Date()) // 'date'
type(/foo/) // 'regexp'
type('type') // 'string'
type(global) // 'global'
type(new String('foo') // 'object'

Methods

(static) canonicalize(value, stackopt, typeHintopt) → {Object|Array|function|string|undefined}

Source:
See:
  • exports.stringify

Return a new Thing that has the keys in sorted order. Recursive.

If the Thing...

  • has already been seen, return string '[Circular]'
  • is undefined, return string '[undefined]'
  • is null, return value null
  • is some other primitive, return the value
  • is not a primitive or an Array, Object, or Function, return the value of the Thing's toString() method
  • is a non-empty Array, Object, or Function, return the result of calling this function again.
  • is an empty Array, Object, or Function, return the result of calling emptyRepresentation()
Parameters:
NameTypeAttributesDefaultDescription
value*

Thing to inspect. May or may not have properties.

stackArray<optional>
[]

Stack of seen values

typeHintstring<optional>

Type hint

Returns:
Type
Object | Array | function | string | undefined

(static) clean(str) → {string}

Source:

Strip the function definition from str, and re-indent for pre whitespace.

Parameters:
NameTypeDescription
strstring
Returns:
Type
string

(static) escape(html) → {string}

Source:

Escape special characters in the given string of html.

Parameters:
NameTypeDescription
htmlstring
Returns:
Type
string

(static) files(dir, extopt, retopt) → {Array}

Source:

Lookup files in the given dir.

Parameters:
NameTypeAttributesDefaultDescription
dirstring
extArray.<string><optional>
['.js']
retArray<optional>
[]
Returns:
Type
Array

(static) getError(err) → {Error}

Source:

Generate an undefined error if err is not defined.

Parameters:
NameTypeDescription
errError
Returns:
Type
Error

(static) highlightTags(name)

Source:

Highlight the contents of tag name.

Parameters:
NameTypeDescription
namestring

(static) isPromise(value) → {boolean}

Source:

Crude, but effective.

Parameters:
NameTypeDescription
value*
Returns:

Whether or not value is a Promise

Type
boolean

(static) isString(obj) → {boolean}

Source:

Test if the given obj is type of string.

Parameters:
NameTypeDescription
objObject
Returns:
Type
boolean

(static) noop()

Source:

It's a noop.

(static) parseQuery(qs) → {Object}

Source:

Parse the given qs.

Parameters:
NameTypeDescription
qsstring
Returns:
Type
Object

(static) slug(str) → {string}

Source:

Compute a slug from the given str.

Parameters:
NameTypeDescription
strstring
Returns:
Type
string

(static) stackTraceFilter() → {function}

This Filter based on mocha-clean module.(see: github.com/rstacruz/mocha-clean)

Source:

When invoking this function you get a filter function that get the Error.stack as an input,
and return a prettify output.
(i.e: strip Mocha and internal node functions from stack trace).

Returns:
Type
function

(static) stringify(value) → {string}

Source:
See:
  • exports.type

Stringify value. Different behavior depending on type of value:

  • If value is undefined or null, return '[undefined]' or '[null]', respectively.
  • If value is not an object, function or array, return result of value.toString() wrapped in double-quotes.
  • If value is an empty object, function, or array, return result of function
    emptyRepresentation.
  • If value has properties, call exports.canonicalize on it, then return result of
    JSON.stringify().
Parameters:
NameTypeDescription
value*
Returns:
Type
string

(static) undefinedError() → {Error}

Source:

Generate an undefined error with a message warning the user.

Returns:
Type
Error

(static) watch(files, fn)

Source:

Watch the given files for changes
and invoke fn(file) on modification.

Parameters:
NameTypeDescription
filesArray
fnfunction

(inner) emptyRepresentation(value, typeHint) → {string}

Source:

If a value could have properties, and has none, this function is called,
which returns a string representation of the empty value.

Functions w/ no properties return '[Function]'
Arrays w/ length === 0 return '[]'
Objects w/ no properties return '{}'
All else: return result of value.toString()

Parameters:
NameTypeDescription
value*

The value to inspect.

typeHintstring

The type of the value

Returns:
Type
string

(inner) highlight(js) → {string}

Source:

Highlight the given string of js.

Parameters:
NameTypeDescription
jsstring
Returns:
Type
string

(inner) ignored(path) → {boolean}

Source:

Ignored files.

Parameters:
NameTypeDescription
pathstring
Returns:
Type
boolean

(inner) jsonStringify(object, spacesopt, depthopt) → {*}

Source:

like JSON.stringify but more sense.

Parameters:
NameTypeAttributesDescription
objectObject
spacesnumber<optional>
depthnumber<optional>
Returns:
Type
*