lodash.uniqueid
Advanced tools
Comparing version 4.0.0 to 4.0.1
141
index.js
/** | ||
* lodash 4.0.0 (Custom Build) <https://lodash.com/> | ||
* lodash (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modularize exports="npm" -o ./` | ||
* Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/> | ||
* Copyright jQuery Foundation and other contributors <https://jquery.org/> | ||
* Released under MIT license <https://lodash.com/license> | ||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> | ||
* Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
* Available under MIT license <https://lodash.com/license> | ||
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
*/ | ||
var toString = require('lodash.tostring'); | ||
/** Used as references for various `Number` constants. */ | ||
var INFINITY = 1 / 0; | ||
/** `Object#toString` result references. */ | ||
var symbolTag = '[object Symbol]'; | ||
/** Detect free variable `global` from Node.js. */ | ||
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; | ||
/** Detect free variable `self`. */ | ||
var freeSelf = typeof self == 'object' && self && self.Object === Object && self; | ||
/** Used as a reference to the global object. */ | ||
var root = freeGlobal || freeSelf || Function('return this')(); | ||
/** Used for built-in method references. */ | ||
var objectProto = Object.prototype; | ||
/** Used to generate unique IDs. */ | ||
@@ -15,8 +32,118 @@ var idCounter = 0; | ||
/** | ||
* Generates a unique ID. If `prefix` is given the ID is appended to it. | ||
* Used to resolve the | ||
* [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | ||
* of values. | ||
*/ | ||
var objectToString = objectProto.toString; | ||
/** Built-in value references. */ | ||
var Symbol = root.Symbol; | ||
/** Used to convert symbols to primitives and strings. */ | ||
var symbolProto = Symbol ? Symbol.prototype : undefined, | ||
symbolToString = symbolProto ? symbolProto.toString : undefined; | ||
/** | ||
* The base implementation of `_.toString` which doesn't convert nullish | ||
* values to empty strings. | ||
* | ||
* @private | ||
* @param {*} value The value to process. | ||
* @returns {string} Returns the string. | ||
*/ | ||
function baseToString(value) { | ||
// Exit early for strings to avoid a performance hit in some environments. | ||
if (typeof value == 'string') { | ||
return value; | ||
} | ||
if (isSymbol(value)) { | ||
return symbolToString ? symbolToString.call(value) : ''; | ||
} | ||
var result = (value + ''); | ||
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; | ||
} | ||
/** | ||
* 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 _ | ||
* @since 4.0.0 | ||
* @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 classified as a `Symbol` primitive or object. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.0.0 | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`. | ||
* @example | ||
* | ||
* _.isSymbol(Symbol.iterator); | ||
* // => true | ||
* | ||
* _.isSymbol('abc'); | ||
* // => false | ||
*/ | ||
function isSymbol(value) { | ||
return typeof value == 'symbol' || | ||
(isObjectLike(value) && objectToString.call(value) == symbolTag); | ||
} | ||
/** | ||
* Converts `value` to a string. An empty string is returned for `null` | ||
* and `undefined` values. The sign of `-0` is preserved. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.0.0 | ||
* @category Lang | ||
* @param {*} value The value to process. | ||
* @returns {string} Returns the string. | ||
* @example | ||
* | ||
* _.toString(null); | ||
* // => '' | ||
* | ||
* _.toString(-0); | ||
* // => '-0' | ||
* | ||
* _.toString([1, 2, 3]); | ||
* // => '1,2,3' | ||
*/ | ||
function toString(value) { | ||
return value == null ? '' : baseToString(value); | ||
} | ||
/** | ||
* Generates a unique ID. If `prefix` is given, the ID is appended to it. | ||
* | ||
* @static | ||
* @since 0.1.0 | ||
* @memberOf _ | ||
* @category Util | ||
* @param {string} [prefix] The value to prefix the ID with. | ||
* @param {string} [prefix=''] The value to prefix the ID with. | ||
* @returns {string} Returns the unique ID. | ||
@@ -23,0 +150,0 @@ * @example |
{ | ||
"name": "lodash.uniqueid", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "The lodash method `_.uniqueId` exported as a module.", | ||
@@ -12,10 +12,7 @@ "homepage": "https://lodash.com/", | ||
"John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)", | ||
"Blaine Bublitz <blaine@iceddev.com> (https://github.com/phated)", | ||
"Blaine Bublitz <blaine.bublitz@gmail.com> (https://github.com/phated)", | ||
"Mathias Bynens <mathias@qiwi.be> (https://mathiasbynens.be/)" | ||
], | ||
"repository": "lodash/lodash", | ||
"scripts": { "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" }, | ||
"dependencies": { | ||
"lodash.tostring": "^4.0.0" | ||
} | ||
"scripts": { "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" } | ||
} |
@@ -1,2 +0,2 @@ | ||
# lodash.uniqueid v4.0.0 | ||
# lodash.uniqueid v4.0.1 | ||
@@ -18,2 +18,2 @@ The [lodash](https://lodash.com/) method `_.uniqueId` exported as a [Node.js](https://nodejs.org/) module. | ||
See the [documentation](https://lodash.com/docs#uniqueId) or [package source](https://github.com/lodash/lodash/blob/4.0.0-npm-packages/lodash.uniqueid) for more details. | ||
See the [documentation](https://lodash.com/docs#uniqueId) or [package source](https://github.com/lodash/lodash/blob/4.0.1-npm-packages/lodash.uniqueid) for more details. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7256
0
146
1
- Removedlodash.tostring@^4.0.0
- Removedlodash.tostring@4.1.4(transitive)