Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Latest commit

 

History

History
201 lines (138 loc) · 5.48 KB

README.md

File metadata and controls

201 lines (138 loc) · 5.48 KB

Spotlight.js v1.2.0

spotlight

spotlight

spotlight

#

(Object): The primary namespace.


spotlight.byKind(kind, [options={}])

#

Crawls environment objects logging all object properties whose values are of a specified constructor instance, [[Class]], or type.

Arguments

  1. kind (Function|string): The constructor, [[Class]], or type to check against.
  2. [options={}] (Object): The options object.

Example

// by constructor
spotlight.byKind(jQuery);

// or by `[[Class]]`
spotlight.byKind('RegExp');

// or by type
spotlight.byKind('undefined');

// or special kind "constructor"
spotlight.byKind('constructor');

spotlight.byName(name, [options={}])

#

Crawls environment objects logging all object properties of the specified name.

Arguments

  1. name (string): The property name to search for.
  2. [options={}] (Object): The options object.

Example

// basic
spotlight.byName('length');
// => window.length -> (number) 0

// or with options
// (finds all "map" properties on jQuery)
spotlight.byName('map', { 'object': jQuery, 'path': '$' });
// => $.map -> (function) function(a,b,c){...}
// => $.fn.map -> (function) function(a){...}

spotlight.byValue(value, [options={}])

#

Crawls environment objects logging all object properties whose values are a match for the specified value, using SameValueZero for equality comparisons.

Note: SameValueZero is like strict equality, e.g. ===, except that NaN matches NaN. See the ES6 spec for more details.

Arguments

  1. value (*): The value to search for.
  2. [options={}] (Object): The options object.

Example

// basic
spotlight.byValue(0);
// => window.pageXOffset -> (number) 0
// => window.screenX -> (number) 0
// => window.length -> (number) 0

spotlight.custom(callback, [options={}])

#

Crawls environment objects executing callback, passing the current value, key, and object as arguments, against each object encountered and logs properties for which callback returns true.

Arguments

  1. callback (Function): A function executed per object.
  2. [options={}] (Object): The options object.

Example

// filter by property names containing "oo"
spotlight.custom(function(value, key) { return key.indexOf('oo') > -1; });

// or filter by falsey values
spotlight.custom(function(value) { return !value; });

spotlight.debug(value)

#

This function enables or disables debug mode for all spotlight methods.

Arguments

  1. value (boolean): The flag value.

Example

spotlight.debug(true);
spotlight.byName('length');
// => [['window.length -> (number)', 0]]

spotlight.runInContext([context=root])

#

Create a new spotlight object using the given context object.

Arguments

  1. [context=root] (Object): The context object.

Returns

(Object): Returns a new spotlight object.


spotlight.version

#

(string): The semantic version number.