Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

spotlight

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spotlight - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

11

package.json
{
"name": "spotlight",
"version": "1.0.0",
"version": "1.1.0",
"description": "An object crawler/property search library that works on nearly all JavaScript platforms.",
"homepage": "https://github.com/bestiejs/spotlight.js",
"license": "MIT",
"main": "spotlight.js",
"keywords": ["crawl", "find", "search", "utility"],
"keywords": "crawl, find, search, utility",
"author": "John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)",

@@ -14,3 +13,2 @@ "contributors": [

],
"bugs": "https://github.com/bestiejs/spotlight.js/issues",
"repository": "bestiejs/spotlight.js",

@@ -21,2 +19,7 @@ "scripts": { "test": "echo \"See the repository CONTRIBUTING.md for testing instructions.\"" },

},
"devDependencies": {
"qunit-extras": "~1.3.0",
"qunitjs": "~1.11.0",
"requirejs": "~2.1.15"
},
"engines": [

@@ -23,0 +26,0 @@ "node",

@@ -1,19 +0,14 @@

# Spotlight.js <sup>v1.0.0</sup>
# Spotlight.js v1.1.0
An object crawler/property search library that works on nearly all JavaScript platforms<sup><a name="fnref1" href="#fn1">1</a></sup>.
An object crawler/property search library that works on nearly all JavaScript platforms.
## BestieJS
Spotlight.js is part of the BestieJS *"Best in Class"* module collection. This means we promote solid browser/environment support, ES5+ precedents, unit testing, and plenty of documentation.
## Documentation
The documentation for Spotlight.js can be viewed here: [/doc/README.md](https://github.com/bestiejs/spotlight.js/blob/master/doc/README.md#readme)
* [doc/README.md](https://github.com/bestiejs/spotlight.js/blob/master/doc/README.md#readme)
* [wiki/Roadmap](https://github.com/bestiejs/spotlight.js/wiki/Roadmap)
For a list of upcoming features, check out our [roadmap](https://github.com/bestiejs/spotlight.js/wiki/Roadmap).
## Installation
## Installation and usage
Spotlight.js’ only hard dependency is [Lo-Dash](https://lodash.com/).
Spotlight.js’ only hard dependency is [Lo-Dash](http://lodash.com/).
In a browser:

@@ -26,32 +21,24 @@

Via [npm](http://npmjs.org/):
In an AMD loader:
```bash
npm install spotlight
```
In [Node.js](http://nodejs.org/) and [RingoJS](http://ringojs.org/):
```js
var spotlight = require('spotlight');
require({
'paths': {
'spotlight': 'path/to/spotlight',
'lodash': 'path/to/lodash'
}
},
['spotlight'], function(spotlight) {/*…*/});
```
In [Rhino](http://www.mozilla.org/rhino/):
Using npm:
```js
load('spotlight.js');
```bash
$ npm i --save spotlight
```
In an AMD loader like [RequireJS](http://requirejs.org/):
In Node.js:
```js
require({
'paths': {
'spotlight': 'path/to/spotlight',
'lodash': 'path/to/lodash'
}
},
['spotlight'], function(spotlight) {
spotlight.byKind('constructor');
});
var spotlight = require('spotlight');
```

@@ -93,7 +80,10 @@

## Footnotes
## Support
1. Spotlight.js has been tested in at least Chrome 33-34, Firefox 27-28, IE 6-11, Opera 19-20, Safari 5-7, Node.js 0.6.21~0.10.26, Narwhal 0.3.2, PhantomJS 1.9.2, RingoJS 0.9, and Rhino 1.7RC5.
<a name="fn1" title="Jump back to footnote 1 in the text." href="#fnref1">&#8617;</a>
Tested in Chrome 38-39, Firefox 32-33, IE 6-11, Opera 25-26, Safari 5-8, Node.js 0.8.26~0.10.33, PhantomJS 1.9.7, RingoJS 0.9, & Rhino 1.7RC5.
## BestieJS
Spotlight.js is part of the BestieJS *“Best in Class”* module collection. This means we promote solid browser/environment support, ES5+ precedents, unit testing, & plenty of documentation.
## Author

@@ -100,0 +90,0 @@

/*!
* Spotlight.js v1.0.0 <https://github.com/bestiejs/spotlight.js/>
* Spotlight.js v1.1.0 <https://github.com/bestiejs/spotlight.js/>
* Copyright 2011-2014 John-David Dalton <http://allyoucanleet.com/>

@@ -14,2 +14,8 @@ * Based on Waldo <https://github.com/angus-c/waldo/>,

/** Used to assign default `context` object properties */
var contextProps = [
'console', 'document', 'environment', 'exports', 'Function', 'Iterator',
'java', 'JSON', 'Object', 'phantom', 'print', 'RegExp', 'String'
];
/** Used to determine if values are of the language type `Object` */

@@ -58,3 +64,3 @@ var objectTypes = {

var result = freeExports && freeRequire(id);
} catch(e) { }
} catch(e) {}
return result || null;

@@ -74,10 +80,17 @@ }

// exit early if unable to acquire Lo-Dash
var _ = context && context._ || req('lodash') || root._;
var _ = context && context._ || !freeDefine && req('lodash') || root._;
if (!_) {
return { 'runInContext': runInContext };
}
context || (context = root);
// Avoid issues with some ES3 environments that attempt to use values, named
// after built-in constructors like `Object`, for the creation of literals.
// ES5 clears this up by stating that literals must use built-in constructors.
// See http://es5.github.io/#x11.1.5.
var originalContext = context || root;
context = context ? _.defaults(root.Object(), context, _.pick(root, contextProps)) : root;
/** Native constructor references */
var Function = context.Function,
Iterator = context.Iterator,
Object = context.Object,

@@ -97,3 +110,3 @@ RegExp = context.RegExp,

.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
.replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
.replace(/\s?toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
);

@@ -108,6 +121,2 @@

var filters = {
'custom': function(value, key, object) {
// the `this` binding is set by `crawl()`
return value.call(this, object[key], key, object);
},
'kind': function(value, key, object) {

@@ -120,7 +129,10 @@ var kind = [value, value = object[key]][0];

},
'name': function(value, key, object) {
'name': function(value, key) {
return value == key;
},
'value': function(value, key, object) {
return object[key] === value;
return value === value
? object[key] === value
// special case for `NaN`
: object[key] !== object[key];
}

@@ -139,3 +151,3 @@ };

var result = 'value' in getDescriptor(o, o);
} catch(e) { };
} catch(e) {};
return !!result;

@@ -151,4 +163,4 @@ }()),

var o = Iterator({ '': 1 });
for (o in o) { }
} catch(e) { }
for (o in o) {}
} catch(e) {}
return _.isArray(o);

@@ -159,3 +171,3 @@ }())

/** Used as the starting point(s) for the object crawler */
var defaultRoots = [{ 'object': context, 'path': 'window' }];
var defaultRoots = [{ 'object': originalContext, 'path': 'window' }];

@@ -166,4 +178,4 @@ // set `defaultRoots` for CLI environments like Narwhal, Node.js, or RingoJS

// for the Narwhal REPL
if (context != freeGlobal) {
defaultRoots.unshift({ 'object': context, 'path': '<module scope>' });
if (originalContext != freeGlobal) {
defaultRoots.unshift({ 'object': originalContext, 'path': '<module scope>' });
}

@@ -226,3 +238,3 @@ // avoid explicitly crawling `exports` if it's crawled indirectly

// iterators will assign an array to `key`
callback(key[1], key[0], object);
callback(key[1], key[0]);
}

@@ -244,3 +256,3 @@ }

}
callback(value, key, object);
callback(value, key);
}

@@ -263,3 +275,3 @@ }

var result = _.result(/^\[object (.*?)\]$/.exec(toString.call(value)), 1);
} catch(e) { }
} catch(e) {}

@@ -299,3 +311,3 @@ return result || '';

}
} catch(e) { }
} catch(e) {}
}

@@ -329,3 +341,3 @@ return result || getClass(value) ||

function isNative(value) {
return typeof value == 'function' && reNative.test(fnToString.call(value));
return _.isFunction(value) && reNative.test(fnToString.call(value));
}

@@ -363,5 +375,10 @@

function crawl(callback, callbackArg, options) {
callback = filters[callback] || callback;
options || (options = {});
if (callback == 'custom') {
var isCustom = true;
} else {
isCustom = false;
callback = filters[callback];
}
var data,

@@ -374,12 +391,12 @@ index,

roots = defaultRoots.slice(),
object = options.object || roots[0].object,
object = options.object,
path = options.path,
result = [];
// resolve `undefined` path
if (path == null) {
path = _.result(_.find(roots, { 'object': object }), 'path') || '<object>';
}
// resolve object roots
if (options.object) {
if (object) {
// resolve `undefined` path
if (path == null) {
path = _.result(_.find(roots, { 'object': object }), 'path') || '<object>';
}
roots = [{ 'object': object, 'path': path }];

@@ -418,15 +435,20 @@ }

pool.push({ 'object': value, 'path': path + separator + key, 'pool': pool });
queue[queue.length] = pool[pool.length - 1];
queue.push(_.last(pool));
}
}
// if filter passed, log it
if (callback.call(data, callbackArg, key, object)) {
result.push([
if (
isCustom
? callbackArg.call(data, value, key, object)
: callback(callbackArg, key, object)
) {
value = [
path + separator + key + ' -> (' +
(true && pooled ? '<' + pooled.path + '>' : getKindOf(value).toLowerCase()) + ')',
(pooled ? '<' + pooled.path + '>' : getKindOf(value).toLowerCase()) + ')',
value
]);
log('text', result[result.length - 1][0], value);
];
result.push(value);
log('text', value[0], value[1]);
}
} catch(e) { }
} catch(e) {}
});

@@ -487,3 +509,3 @@ } while ((data = queue[index++]));

if (!isHostType(console, 'log')) {
log = function() { };
log = function() {};
}

@@ -548,4 +570,8 @@ // avoid Safari 2 crash bug when passing more than 1 argument

* Crawls environment objects logging all object properties whose values are
* a strict match for the specified value.
* 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](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* for more details.
*
* @memberOf spotlight

@@ -618,3 +644,3 @@ * @param {*} value The value to search for.

*/
spotlight.version = '1.0.0';
spotlight.version = '1.1.0';

@@ -639,3 +665,7 @@ spotlight.byKind = byKind;

// define as an anonymous module so, through path mapping, it can be aliased
define(spotlight);
define(['lodash'], function(_) {
return runInContext({
'_': _
});
});
}

@@ -642,0 +672,0 @@ // check for `exports` after `define` in case a build optimizer adds an `exports` object

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc