-
Notifications
You must be signed in to change notification settings - Fork 7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
378 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
Copyright jQuery Foundation and other contributors <https://jquery.org/> | ||
|
||
Based on Underscore.js, copyright Jeremy Ashkenas, | ||
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/> | ||
|
||
This software consists of voluntary contributions made by many | ||
individuals. For exact contribution history, see the revision history | ||
available at https://github.com/lodash/lodash | ||
|
||
The following license applies to all parts of this software except as | ||
documented below: | ||
|
||
==== | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
==== | ||
|
||
Copyright and related rights for sample code are waived via CC0. Sample | ||
code is defined as all source code displayed within the prose of the | ||
documentation. | ||
|
||
CC0: http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
==== | ||
|
||
Files located in the node_modules and vendor directories are externally | ||
maintained libraries used by this software which have their own | ||
licenses; we recommend you read them, as their terms may differ from the | ||
terms above. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# lodash.nth v4.11.0 | ||
|
||
The [lodash](https://lodash.com/) method `_.nth` exported as a [Node.js](https://nodejs.org/) module. | ||
|
||
## Installation | ||
|
||
Using npm: | ||
```bash | ||
$ {sudo -H} npm i -g npm | ||
$ npm i --save lodash.nth | ||
``` | ||
|
||
In Node.js: | ||
```js | ||
var nth = require('lodash.nth'); | ||
``` | ||
|
||
See the [documentation](https://lodash.com/docs#nth) or [package source](https://github.com/lodash/lodash/blob/4.11.0-npm-packages/lodash.nth) for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,295 @@ | ||
/** | ||
* lodash 4.11.0 (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 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
*/ | ||
|
||
/** Used as references for various `Number` constants. */ | ||
var INFINITY = 1 / 0, | ||
MAX_SAFE_INTEGER = 9007199254740991, | ||
MAX_INTEGER = 1.7976931348623157e+308, | ||
NAN = 0 / 0; | ||
|
||
/** `Object#toString` result references. */ | ||
var funcTag = '[object Function]', | ||
genTag = '[object GeneratorFunction]', | ||
symbolTag = '[object Symbol]'; | ||
|
||
/** Used to match leading and trailing whitespace. */ | ||
var reTrim = /^\s+|\s+$/g; | ||
|
||
/** Used to detect bad signed hexadecimal string values. */ | ||
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; | ||
|
||
/** Used to detect binary string values. */ | ||
var reIsBinary = /^0b[01]+$/i; | ||
|
||
/** Used to detect octal string values. */ | ||
var reIsOctal = /^0o[0-7]+$/i; | ||
|
||
/** Used to detect unsigned integer values. */ | ||
var reIsUint = /^(?:0|[1-9]\d*)$/; | ||
|
||
/** Built-in method references without a dependency on `root`. */ | ||
var freeParseInt = parseInt; | ||
|
||
/** | ||
* Checks if `value` is a valid array-like index. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. | ||
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`. | ||
*/ | ||
function isIndex(value, length) { | ||
value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1; | ||
length = length == null ? MAX_SAFE_INTEGER : length; | ||
return value > -1 && value % 1 == 0 && value < length; | ||
} | ||
|
||
/** 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; | ||
|
||
/** | ||
* The base implementation of `_.nth` which doesn't coerce `n` to an integer. | ||
* | ||
* @private | ||
* @param {Array} array The array to query. | ||
* @param {number} n The index of the element to return. | ||
* @returns {*} Returns the nth element of `array`. | ||
*/ | ||
function baseNth(array, n) { | ||
var length = array.length; | ||
if (!length) { | ||
return; | ||
} | ||
n += n < 0 ? length : 0; | ||
return isIndex(n, length) ? array[n] : undefined; | ||
} | ||
|
||
/** | ||
* Gets the nth element of `array`. If `n` is negative, the nth element | ||
* from the end is returned. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.11.0 | ||
* @category Array | ||
* @param {Array} array The array to query. | ||
* @param {number} [n=0] The index of the element to return. | ||
* @returns {*} Returns the nth element of `array`. | ||
* @example | ||
* | ||
* var array = ['a', 'b', 'c', 'd']; | ||
* | ||
* _.nth(array, 1); | ||
* // => 'b' | ||
* | ||
* _.nth(array, -2); | ||
* // => 'c'; | ||
*/ | ||
function nth(array, n) { | ||
return (array && array.length) ? baseNth(array, toInteger(n)) : undefined; | ||
} | ||
|
||
/** | ||
* Checks if `value` is classified as a `Function` object. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 0.1.0 | ||
* @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 and weak map 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](http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types) | ||
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 0.1.0 | ||
* @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 _ | ||
* @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); | ||
} | ||
|
||
/** | ||
* Converts `value` to an integer. | ||
* | ||
* **Note:** This function is loosely based on | ||
* [`ToInteger`](http://www.ecma-international.org/ecma-262/6.0/#sec-tointeger). | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.0.0 | ||
* @category Lang | ||
* @param {*} value The value to convert. | ||
* @returns {number} Returns the converted integer. | ||
* @example | ||
* | ||
* _.toInteger(3); | ||
* // => 3 | ||
* | ||
* _.toInteger(Number.MIN_VALUE); | ||
* // => 0 | ||
* | ||
* _.toInteger(Infinity); | ||
* // => 1.7976931348623157e+308 | ||
* | ||
* _.toInteger('3'); | ||
* // => 3 | ||
*/ | ||
function toInteger(value) { | ||
if (!value) { | ||
return value === 0 ? value : 0; | ||
} | ||
value = toNumber(value); | ||
if (value === INFINITY || value === -INFINITY) { | ||
var sign = (value < 0 ? -1 : 1); | ||
return sign * MAX_INTEGER; | ||
} | ||
var remainder = value % 1; | ||
return value === value ? (remainder ? value - remainder : value) : 0; | ||
} | ||
|
||
/** | ||
* Converts `value` to a number. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.0.0 | ||
* @category Lang | ||
* @param {*} value The value to process. | ||
* @returns {number} Returns the number. | ||
* @example | ||
* | ||
* _.toNumber(3); | ||
* // => 3 | ||
* | ||
* _.toNumber(Number.MIN_VALUE); | ||
* // => 5e-324 | ||
* | ||
* _.toNumber(Infinity); | ||
* // => Infinity | ||
* | ||
* _.toNumber('3'); | ||
* // => 3 | ||
*/ | ||
function toNumber(value) { | ||
if (typeof value == 'number') { | ||
return value; | ||
} | ||
if (isSymbol(value)) { | ||
return NAN; | ||
} | ||
if (isObject(value)) { | ||
var other = isFunction(value.valueOf) ? value.valueOf() : value; | ||
value = isObject(other) ? (other + '') : other; | ||
} | ||
if (typeof value != 'string') { | ||
return value === 0 ? value : +value; | ||
} | ||
value = value.replace(reTrim, ''); | ||
var isBinary = reIsBinary.test(value); | ||
return (isBinary || reIsOctal.test(value)) | ||
? freeParseInt(value.slice(2), isBinary ? 2 : 8) | ||
: (reIsBadHex.test(value) ? NAN : +value); | ||
} | ||
|
||
module.exports = nth; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "lodash.nth", | ||
"version": "4.11.0", | ||
"description": "The lodash method `_.nth` exported as a module.", | ||
"homepage": "https://lodash.com/", | ||
"icon": "https://lodash.com/icon.svg", | ||
"license": "MIT", | ||
"keywords": "lodash-modularized, nth", | ||
"author": "John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)", | ||
"contributors": [ | ||
"John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)", | ||
"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.\"" } | ||
} |