lodash._stack
Advanced tools
Comparing version 4.0.2 to 4.1.0
419
index.js
/** | ||
* lodash 4.0.2 (Custom Build) <https://lodash.com/> | ||
* lodash 4.1.0 (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modularize exports="npm" -o ./` | ||
@@ -9,3 +9,2 @@ * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/> | ||
*/ | ||
var MapCache = require('lodash._mapcache'); | ||
@@ -15,12 +14,284 @@ /** Used as the size to enable large array optimizations. */ | ||
/** Used to stand-in for `undefined` hash values. */ | ||
var HASH_UNDEFINED = '__lodash_hash_undefined__'; | ||
/** `Object#toString` result references. */ | ||
var funcTag = '[object Function]', | ||
genTag = '[object GeneratorFunction]'; | ||
/** Used to match `RegExp` [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns). */ | ||
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; | ||
/** Used to detect host constructors (Safari > 5). */ | ||
var reIsHostCtor = /^\[object .+?Constructor\]$/; | ||
/** Used to determine if values are of the language type `Object`. */ | ||
var objectTypes = { | ||
'function': true, | ||
'object': true | ||
}; | ||
/** Detect free variable `exports`. */ | ||
var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) | ||
? exports | ||
: undefined; | ||
/** Detect free variable `module`. */ | ||
var freeModule = (objectTypes[typeof module] && module && !module.nodeType) | ||
? module | ||
: undefined; | ||
/** Detect free variable `global` from Node.js. */ | ||
var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global); | ||
/** Detect free variable `self`. */ | ||
var freeSelf = checkGlobal(objectTypes[typeof self] && self); | ||
/** Detect free variable `window`. */ | ||
var freeWindow = checkGlobal(objectTypes[typeof window] && window); | ||
/** Detect `this` as the global object. */ | ||
var thisGlobal = checkGlobal(objectTypes[typeof this] && this); | ||
/** | ||
* Used as a reference to the global object. | ||
* | ||
* The `this` value is used if it's the global object to avoid Greasemonkey's | ||
* restricted `window` object, otherwise the `window` object is used. | ||
*/ | ||
var root = freeGlobal || | ||
((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) || | ||
freeSelf || thisGlobal || Function('return this')(); | ||
/** | ||
* Checks if `value` is a global object. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {null|Object} Returns `value` if it's a global object, else `null`. | ||
*/ | ||
function checkGlobal(value) { | ||
return (value && value.Object === Object) ? value : null; | ||
} | ||
/** | ||
* Checks if `value` is a host object in IE < 9. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a host object, else `false`. | ||
*/ | ||
function isHostObject(value) { | ||
// Many host objects are `Object` objects that can coerce to strings | ||
// despite having improperly defined `toString` methods. | ||
var result = false; | ||
if (value != null && typeof value.toString != 'function') { | ||
try { | ||
result = !!(value + ''); | ||
} catch (e) {} | ||
} | ||
return result; | ||
} | ||
/** Used for built-in method references. */ | ||
var arrayProto = Array.prototype; | ||
var arrayProto = Array.prototype, | ||
objectProto = Object.prototype; | ||
/** Used to resolve the decompiled source of functions. */ | ||
var funcToString = Function.prototype.toString; | ||
/** Used to check objects for own properties. */ | ||
var hasOwnProperty = objectProto.hasOwnProperty; | ||
/** | ||
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | ||
* of values. | ||
*/ | ||
var objectToString = objectProto.toString; | ||
/** Used to detect if a method is native. */ | ||
var reIsNative = RegExp('^' + | ||
funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') | ||
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' | ||
); | ||
/** Built-in value references. */ | ||
var splice = arrayProto.splice; | ||
/* Built-in method references that are verified to be native. */ | ||
var Map = getNative(root, 'Map'), | ||
nativeCreate = getNative(Object, 'create'); | ||
/** | ||
* Creates an hash object. | ||
* | ||
* @private | ||
* @constructor | ||
* @returns {Object} Returns the new hash object. | ||
*/ | ||
function Hash() {} | ||
/** | ||
* Removes `key` and its value from the hash. | ||
* | ||
* @private | ||
* @param {Object} hash The hash to modify. | ||
* @param {string} key The key of the value to remove. | ||
* @returns {boolean} Returns `true` if the entry was removed, else `false`. | ||
*/ | ||
function hashDelete(hash, key) { | ||
return hashHas(hash, key) && delete hash[key]; | ||
} | ||
/** | ||
* Gets the hash value for `key`. | ||
* | ||
* @private | ||
* @param {Object} hash The hash to query. | ||
* @param {string} key The key of the value to get. | ||
* @returns {*} Returns the entry value. | ||
*/ | ||
function hashGet(hash, key) { | ||
if (nativeCreate) { | ||
var result = hash[key]; | ||
return result === HASH_UNDEFINED ? undefined : result; | ||
} | ||
return hasOwnProperty.call(hash, key) ? hash[key] : undefined; | ||
} | ||
/** | ||
* Checks if a hash value for `key` exists. | ||
* | ||
* @private | ||
* @param {Object} hash The hash to query. | ||
* @param {string} key The key of the entry to check. | ||
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. | ||
*/ | ||
function hashHas(hash, key) { | ||
return nativeCreate ? hash[key] !== undefined : hasOwnProperty.call(hash, key); | ||
} | ||
/** | ||
* Sets the hash `key` to `value`. | ||
* | ||
* @private | ||
* @param {Object} hash The hash to modify. | ||
* @param {string} key The key of the value to set. | ||
* @param {*} value The value to set. | ||
*/ | ||
function hashSet(hash, key, value) { | ||
hash[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; | ||
} | ||
/** | ||
* Creates a map cache object to store key-value pairs. | ||
* | ||
* @private | ||
* @constructor | ||
* @param {Array} [values] The values to cache. | ||
*/ | ||
function MapCache(values) { | ||
var index = -1, | ||
length = values ? values.length : 0; | ||
this.clear(); | ||
while (++index < length) { | ||
var entry = values[index]; | ||
this.set(entry[0], entry[1]); | ||
} | ||
} | ||
/** | ||
* Removes all key-value entries from the map. | ||
* | ||
* @private | ||
* @name clear | ||
* @memberOf MapCache | ||
*/ | ||
function mapClear() { | ||
this.__data__ = { | ||
'hash': new Hash, | ||
'map': Map ? new Map : [], | ||
'string': new Hash | ||
}; | ||
} | ||
/** | ||
* Removes `key` and its value from the map. | ||
* | ||
* @private | ||
* @name delete | ||
* @memberOf MapCache | ||
* @param {string} key The key of the value to remove. | ||
* @returns {boolean} Returns `true` if the entry was removed, else `false`. | ||
*/ | ||
function mapDelete(key) { | ||
var data = this.__data__; | ||
if (isKeyable(key)) { | ||
return hashDelete(typeof key == 'string' ? data.string : data.hash, key); | ||
} | ||
return Map ? data.map['delete'](key) : assocDelete(data.map, key); | ||
} | ||
/** | ||
* Gets the map value for `key`. | ||
* | ||
* @private | ||
* @name get | ||
* @memberOf MapCache | ||
* @param {string} key The key of the value to get. | ||
* @returns {*} Returns the entry value. | ||
*/ | ||
function mapGet(key) { | ||
var data = this.__data__; | ||
if (isKeyable(key)) { | ||
return hashGet(typeof key == 'string' ? data.string : data.hash, key); | ||
} | ||
return Map ? data.map.get(key) : assocGet(data.map, key); | ||
} | ||
/** | ||
* Checks if a map value for `key` exists. | ||
* | ||
* @private | ||
* @name has | ||
* @memberOf MapCache | ||
* @param {string} key The key of the entry to check. | ||
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. | ||
*/ | ||
function mapHas(key) { | ||
var data = this.__data__; | ||
if (isKeyable(key)) { | ||
return hashHas(typeof key == 'string' ? data.string : data.hash, key); | ||
} | ||
return Map ? data.map.has(key) : assocHas(data.map, key); | ||
} | ||
/** | ||
* Sets the map `key` to `value`. | ||
* | ||
* @private | ||
* @name set | ||
* @memberOf MapCache | ||
* @param {string} key The key of the value to set. | ||
* @param {*} value The value to set. | ||
* @returns {Object} Returns the map cache object. | ||
*/ | ||
function mapSet(key, value) { | ||
var data = this.__data__; | ||
if (isKeyable(key)) { | ||
hashSet(typeof key == 'string' ? data.string : data.hash, key, value); | ||
} else if (Map) { | ||
data.map.set(key, value); | ||
} else { | ||
assocSet(data.map, key, value); | ||
} | ||
return this; | ||
} | ||
/** | ||
* Creates a stack cache object to store key-value pairs. | ||
* | ||
* @private | ||
* @constructor | ||
* @param {Array} [values] The values to cache. | ||
@@ -211,2 +482,28 @@ */ | ||
/** | ||
* Gets the native function at `key` of `object`. | ||
* | ||
* @private | ||
* @param {Object} object The object to query. | ||
* @param {string} key The key of the method to get. | ||
* @returns {*} Returns the function if it's native, else `undefined`. | ||
*/ | ||
function getNative(object, key) { | ||
var value = object == null ? undefined : object[key]; | ||
return isNative(value) ? value : undefined; | ||
} | ||
/** | ||
* Checks if `value` is suitable for use as unique object key. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is suitable, else `false`. | ||
*/ | ||
function isKeyable(value) { | ||
var type = typeof value; | ||
return type == 'number' || type == 'boolean' || | ||
(type == 'string' && value != '__proto__') || value == null; | ||
} | ||
/** | ||
* Performs a [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) | ||
@@ -245,2 +542,118 @@ * comparison between two values to determine if they are equivalent. | ||
/** | ||
* Checks if `value` is classified as a `Function` object. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. | ||
* @example | ||
* | ||
* _.isFunction(_); | ||
* // => true | ||
* | ||
* _.isFunction(/abc/); | ||
* // => false | ||
*/ | ||
function isFunction(value) { | ||
// The use of `Object#toString` avoids issues with the `typeof` operator | ||
// in Safari 8 which returns 'object' for typed array constructors, and | ||
// PhantomJS 1.9 which returns 'function' for `NodeList` instances. | ||
var tag = isObject(value) ? objectToString.call(value) : ''; | ||
return tag == funcTag || tag == genTag; | ||
} | ||
/** | ||
* Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. | ||
* (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is an object, else `false`. | ||
* @example | ||
* | ||
* _.isObject({}); | ||
* // => true | ||
* | ||
* _.isObject([1, 2, 3]); | ||
* // => true | ||
* | ||
* _.isObject(_.noop); | ||
* // => true | ||
* | ||
* _.isObject(null); | ||
* // => false | ||
*/ | ||
function isObject(value) { | ||
var type = typeof value; | ||
return !!value && (type == 'object' || type == 'function'); | ||
} | ||
/** | ||
* Checks if `value` is object-like. A value is object-like if it's not `null` | ||
* and has a `typeof` result of "object". | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is object-like, else `false`. | ||
* @example | ||
* | ||
* _.isObjectLike({}); | ||
* // => true | ||
* | ||
* _.isObjectLike([1, 2, 3]); | ||
* // => true | ||
* | ||
* _.isObjectLike(_.noop); | ||
* // => false | ||
* | ||
* _.isObjectLike(null); | ||
* // => false | ||
*/ | ||
function isObjectLike(value) { | ||
return !!value && typeof value == 'object'; | ||
} | ||
/** | ||
* Checks if `value` is a native function. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a native function, else `false`. | ||
* @example | ||
* | ||
* _.isNative(Array.prototype.push); | ||
* // => true | ||
* | ||
* _.isNative(_); | ||
* // => false | ||
*/ | ||
function isNative(value) { | ||
if (value == null) { | ||
return false; | ||
} | ||
if (isFunction(value)) { | ||
return reIsNative.test(funcToString.call(value)); | ||
} | ||
return isObjectLike(value) && | ||
(isHostObject(value) ? reIsNative : reIsHostCtor).test(value); | ||
} | ||
// Avoid inheriting from `Object.prototype` when possible. | ||
Hash.prototype = nativeCreate ? nativeCreate(null) : objectProto; | ||
// Add functions to the `MapCache`. | ||
MapCache.prototype.clear = mapClear; | ||
MapCache.prototype['delete'] = mapDelete; | ||
MapCache.prototype.get = mapGet; | ||
MapCache.prototype.has = mapHas; | ||
MapCache.prototype.set = mapSet; | ||
// Add functions to the `Stack` cache. | ||
@@ -247,0 +660,0 @@ Stack.prototype.clear = stackClear; |
{ | ||
"name": "lodash._stack", | ||
"version": "4.0.2", | ||
"version": "4.1.0", | ||
"description": "The internal lodash function `Stack` exported as a module.", | ||
@@ -15,6 +15,3 @@ "homepage": "https://lodash.com/", | ||
"repository": "lodash/lodash", | ||
"scripts": { "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" }, | ||
"dependencies": { | ||
"lodash._mapcache": "^4.0.0" | ||
} | ||
"scripts": { "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" } | ||
} |
@@ -1,2 +0,2 @@ | ||
# lodash._stack v4.0.2 | ||
# lodash._stack v4.1.0 | ||
@@ -18,2 +18,2 @@ The internal [lodash](https://lodash.com/) function `Stack` exported as a [Node.js](https://nodejs.org/) module. | ||
See the [package source](https://github.com/lodash/lodash/blob/4.0.2-npm-packages/lodash._stack) for more details. | ||
See the [package source](https://github.com/lodash/lodash/blob/4.1.0-npm-packages/lodash._stack) for more details. |
Sorry, the diff of this file is not supported yet
19085
0
601
- Removedlodash._mapcache@^4.0.0
- Removedlodash._mapcache@4.1.5(transitive)