mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 17:47:49 +00:00
Bump to v3.0.0.
This commit is contained in:
22
lodash.times/LICENSE.txt
Normal file
22
lodash.times/LICENSE.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
|
||||
Based on Underscore.js 1.7.0, copyright 2009-2015 Jeremy Ashkenas,
|
||||
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
|
||||
|
||||
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.
|
||||
20
lodash.times/README.md
Normal file
20
lodash.times/README.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# lodash.times v3.0.0
|
||||
|
||||
The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) `_.times` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module.
|
||||
|
||||
## Installation
|
||||
|
||||
Using npm:
|
||||
|
||||
```bash
|
||||
$ {sudo -H} npm i -g npm
|
||||
$ npm i --save lodash.times
|
||||
```
|
||||
|
||||
In Node.js/io.js:
|
||||
|
||||
```js
|
||||
var times = require('lodash.times');
|
||||
```
|
||||
|
||||
See the [documentation](https://lodash.com/docs#times) or [package source](https://github.com/lodash/lodash/blob/3.0.0-npm-packages/lodash.times) for more details.
|
||||
67
lodash.times/index.js
Normal file
67
lodash.times/index.js
Normal file
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* lodash 3.0.0 (Custom Build) <https://lodash.com/>
|
||||
* Build: `lodash modern modularize exports="npm" -o ./`
|
||||
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
|
||||
* Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE>
|
||||
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||
* Available under MIT license <https://lodash.com/license>
|
||||
*/
|
||||
var bindCallback = require('lodash._bindcallback');
|
||||
|
||||
/* Native method references for those with the same name as other `lodash` methods. */
|
||||
var nativeIsFinite = global.isFinite,
|
||||
nativeMin = Math.min;
|
||||
|
||||
/** Used as references for the maximum length and index of an array. */
|
||||
var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1;
|
||||
|
||||
/**
|
||||
* Invokes the iteratee function `n` times, returning an array of the results
|
||||
* of each invocation. The `iteratee` is bound to `thisArg` and invoked with
|
||||
* one argument; (index).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Utility
|
||||
* @param {number} n The number of times to invoke `iteratee`.
|
||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
||||
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
||||
* @returns {Array} Returns the array of results.
|
||||
* @example
|
||||
*
|
||||
* var diceRolls = _.times(3, _.partial(_.random, 1, 6, false));
|
||||
* // => [3, 6, 4]
|
||||
*
|
||||
* _.times(3, function(n) {
|
||||
* mage.castSpell(n);
|
||||
* });
|
||||
* // => invokes `mage.castSpell(n)` three times with `n` of `0`, `1`, and `2` respectively
|
||||
*
|
||||
* _.times(3, function(n) {
|
||||
* this.cast(n);
|
||||
* }, mage);
|
||||
* // => also invokes `mage.castSpell(n)` three times
|
||||
*/
|
||||
function times(n, iteratee, thisArg) {
|
||||
n = +n;
|
||||
|
||||
// Exit early to avoid a JSC JIT bug in Safari 8
|
||||
// where `Array(0)` is treated as `Array(1)`.
|
||||
if (n < 1 || !nativeIsFinite(n)) {
|
||||
return [];
|
||||
}
|
||||
var index = -1,
|
||||
result = Array(nativeMin(n, MAX_ARRAY_LENGTH));
|
||||
|
||||
iteratee = bindCallback(iteratee, thisArg, 1);
|
||||
while (++index < n) {
|
||||
if (index < MAX_ARRAY_LENGTH) {
|
||||
result[index] = iteratee(index);
|
||||
} else {
|
||||
iteratee(index);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
module.exports = times;
|
||||
22
lodash.times/package.json
Normal file
22
lodash.times/package.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "lodash.times",
|
||||
"version": "3.0.0",
|
||||
"description": "The modern build of lodash’s `_.times` as a module.",
|
||||
"homepage": "https://lodash.com/",
|
||||
"icon": "https://lodash.com/icon.svg",
|
||||
"license": "MIT",
|
||||
"keywords": "lodash, lodash-modularized, stdlib, util",
|
||||
"author": "John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)",
|
||||
"contributors": [
|
||||
"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/)",
|
||||
"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._bindcallback": "^3.0.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user