lodash._basetostring
Advanced tools
Comparing version 3.0.1 to 4.12.0
147
index.js
/** | ||
* lodash 3.0.1 (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modern modularize exports="npm" -o ./` | ||
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/> | ||
* lodash (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modularize exports="npm" -o ./` | ||
* 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-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
* Available under MIT license <https://lodash.com/license> | ||
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
*/ | ||
/** Used as references for various `Number` constants. */ | ||
var INFINITY = 1 / 0; | ||
/** `Object#toString` result references. */ | ||
var symbolTag = '[object Symbol]'; | ||
/** 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); | ||
/** | ||
* Converts `value` to a string if it's not one. An empty string is returned | ||
* for `null` or `undefined` values. | ||
* 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; | ||
} | ||
/** Used for built-in method references. */ | ||
var objectProto = Object.prototype; | ||
/** | ||
* 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. | ||
@@ -19,5 +91,64 @@ * @returns {string} Returns the string. | ||
function baseToString(value) { | ||
return value == null ? '' : (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 correctly classified, | ||
* else `false`. | ||
* @example | ||
* | ||
* _.isSymbol(Symbol.iterator); | ||
* // => true | ||
* | ||
* _.isSymbol('abc'); | ||
* // => false | ||
*/ | ||
function isSymbol(value) { | ||
return typeof value == 'symbol' || | ||
(isObjectLike(value) && objectToString.call(value) == symbolTag); | ||
} | ||
module.exports = baseToString; |
{ | ||
"name": "lodash._basetostring", | ||
"version": "3.0.1", | ||
"description": "The modern build of lodash’s internal `baseToString` as a module.", | ||
"version": "4.12.0", | ||
"description": "The internal lodash function `baseToString` exported as a module.", | ||
"homepage": "https://lodash.com/", | ||
@@ -11,5 +11,3 @@ "icon": "https://lodash.com/icon.svg", | ||
"John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)", | ||
"Benjamin Tan <demoneaux@gmail.com> (https://d10.github.io/)", | ||
"Blaine Bublitz <blaine@iceddev.com> (http://www.iceddev.com/)", | ||
"Kit Cambridge <github@kitcambridge.be> (http://kitcambridge.be/)", | ||
"Blaine Bublitz <blaine.bublitz@gmail.com> (https://github.com/phated)", | ||
"Mathias Bynens <mathias@qiwi.be> (https://mathiasbynens.be/)" | ||
@@ -16,0 +14,0 @@ ], |
@@ -1,4 +0,4 @@ | ||
# lodash._basetostring v3.0.1 | ||
# lodash._basetostring v4.12.0 | ||
The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) internal `baseToString` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. | ||
The internal [lodash](https://lodash.com/) function `baseToString` exported as a [Node.js](https://nodejs.org/) module. | ||
@@ -8,3 +8,2 @@ ## Installation | ||
Using npm: | ||
```bash | ||
@@ -15,4 +14,3 @@ $ {sudo -H} npm i -g npm | ||
In Node.js/io.js: | ||
In Node.js: | ||
```js | ||
@@ -22,2 +20,2 @@ var baseToString = require('lodash._basetostring'); | ||
See the [package source](https://github.com/lodash/lodash/blob/3.0.1-npm-packages/lodash._basetostring) for more details. | ||
See the [package source](https://github.com/lodash/lodash/blob/4.12.0-npm-packages/lodash._basetostring) 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
7384
134
1
19