Initial pass
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2017, Jon Schlinkert
|
||||
|
||||
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.
|
||||
+250
File diff suppressed because one or more lines are too long
+208
@@ -0,0 +1,208 @@
|
||||
/*!
|
||||
* fill-range <https://github.com/jonschlinkert/fill-range>
|
||||
*
|
||||
* Copyright (c) 2014-2015, 2017, Jon Schlinkert.
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
var isNumber = require('is-number');
|
||||
var extend = require('extend-shallow');
|
||||
var repeat = require('repeat-string');
|
||||
var toRegex = require('to-regex-range');
|
||||
|
||||
/**
|
||||
* Return a range of numbers or letters.
|
||||
*
|
||||
* @param {String} `start` Start of the range
|
||||
* @param {String} `stop` End of the range
|
||||
* @param {String} `step` Increment or decrement to use.
|
||||
* @param {Function} `fn` Custom function to modify each element in the range.
|
||||
* @return {Array}
|
||||
*/
|
||||
|
||||
function fillRange(start, stop, step, options) {
|
||||
if (typeof start === 'undefined') {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (typeof stop === 'undefined' || start === stop) {
|
||||
// special case, for handling negative zero
|
||||
var isString = typeof start === 'string';
|
||||
if (isNumber(start) && !toNumber(start)) {
|
||||
return [isString ? '0' : 0];
|
||||
}
|
||||
return [start];
|
||||
}
|
||||
|
||||
if (typeof step !== 'number' && typeof step !== 'string') {
|
||||
options = step;
|
||||
step = undefined;
|
||||
}
|
||||
|
||||
if (typeof options === 'function') {
|
||||
options = { transform: options };
|
||||
}
|
||||
|
||||
var opts = extend({step: step}, options);
|
||||
if (opts.step && !isValidNumber(opts.step)) {
|
||||
if (opts.strictRanges === true) {
|
||||
throw new TypeError('expected options.step to be a number');
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
opts.isNumber = isValidNumber(start) && isValidNumber(stop);
|
||||
if (!opts.isNumber && !isValid(start, stop)) {
|
||||
if (opts.strictRanges === true) {
|
||||
throw new RangeError('invalid range arguments: ' + util.inspect([start, stop]));
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
opts.isPadded = isPadded(start) || isPadded(stop);
|
||||
opts.toString = opts.stringify
|
||||
|| typeof opts.step === 'string'
|
||||
|| typeof start === 'string'
|
||||
|| typeof stop === 'string'
|
||||
|| !opts.isNumber;
|
||||
|
||||
if (opts.isPadded) {
|
||||
opts.maxLength = Math.max(String(start).length, String(stop).length);
|
||||
}
|
||||
|
||||
// support legacy minimatch/fill-range options
|
||||
if (typeof opts.optimize === 'boolean') opts.toRegex = opts.optimize;
|
||||
if (typeof opts.makeRe === 'boolean') opts.toRegex = opts.makeRe;
|
||||
return expand(start, stop, opts);
|
||||
}
|
||||
|
||||
function expand(start, stop, options) {
|
||||
var a = options.isNumber ? toNumber(start) : start.charCodeAt(0);
|
||||
var b = options.isNumber ? toNumber(stop) : stop.charCodeAt(0);
|
||||
|
||||
var step = Math.abs(toNumber(options.step)) || 1;
|
||||
if (options.toRegex && step === 1) {
|
||||
return toRange(a, b, start, stop, options);
|
||||
}
|
||||
|
||||
var zero = {greater: [], lesser: []};
|
||||
var asc = a < b;
|
||||
var arr = new Array(Math.round((asc ? b - a : a - b) / step));
|
||||
var idx = 0;
|
||||
|
||||
while (asc ? a <= b : a >= b) {
|
||||
var val = options.isNumber ? a : String.fromCharCode(a);
|
||||
if (options.toRegex && (val >= 0 || !options.isNumber)) {
|
||||
zero.greater.push(val);
|
||||
} else {
|
||||
zero.lesser.push(Math.abs(val));
|
||||
}
|
||||
|
||||
if (options.isPadded) {
|
||||
val = zeros(val, options);
|
||||
}
|
||||
|
||||
if (options.toString) {
|
||||
val = String(val);
|
||||
}
|
||||
|
||||
if (typeof options.transform === 'function') {
|
||||
arr[idx++] = options.transform(val, a, b, step, idx, arr, options);
|
||||
} else {
|
||||
arr[idx++] = val;
|
||||
}
|
||||
|
||||
if (asc) {
|
||||
a += step;
|
||||
} else {
|
||||
a -= step;
|
||||
}
|
||||
}
|
||||
|
||||
if (options.toRegex === true) {
|
||||
return toSequence(arr, zero, options);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
function toRange(a, b, start, stop, options) {
|
||||
if (options.isPadded) {
|
||||
return toRegex(start, stop, options);
|
||||
}
|
||||
|
||||
if (options.isNumber) {
|
||||
return toRegex(Math.min(a, b), Math.max(a, b), options);
|
||||
}
|
||||
|
||||
var start = String.fromCharCode(Math.min(a, b));
|
||||
var stop = String.fromCharCode(Math.max(a, b));
|
||||
return '[' + start + '-' + stop + ']';
|
||||
}
|
||||
|
||||
function toSequence(arr, zeros, options) {
|
||||
var greater = '', lesser = '';
|
||||
if (zeros.greater.length) {
|
||||
greater = zeros.greater.join('|');
|
||||
}
|
||||
if (zeros.lesser.length) {
|
||||
lesser = '-(' + zeros.lesser.join('|') + ')';
|
||||
}
|
||||
var res = greater && lesser
|
||||
? greater + '|' + lesser
|
||||
: greater || lesser;
|
||||
|
||||
if (options.capture) {
|
||||
return '(' + res + ')';
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
function zeros(val, options) {
|
||||
if (options.isPadded) {
|
||||
var str = String(val);
|
||||
var len = str.length;
|
||||
var dash = '';
|
||||
if (str.charAt(0) === '-') {
|
||||
dash = '-';
|
||||
str = str.slice(1);
|
||||
}
|
||||
var diff = options.maxLength - len;
|
||||
var pad = repeat('0', diff);
|
||||
val = (dash + pad + str);
|
||||
}
|
||||
if (options.stringify) {
|
||||
return String(val);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
function toNumber(val) {
|
||||
return Number(val) || 0;
|
||||
}
|
||||
|
||||
function isPadded(str) {
|
||||
return /^-?0\d/.test(str);
|
||||
}
|
||||
|
||||
function isValid(min, max) {
|
||||
return (isValidNumber(min) || isValidLetter(min))
|
||||
&& (isValidNumber(max) || isValidLetter(max));
|
||||
}
|
||||
|
||||
function isValidLetter(ch) {
|
||||
return typeof ch === 'string' && ch.length === 1 && /^\w+$/.test(ch);
|
||||
}
|
||||
|
||||
function isValidNumber(n) {
|
||||
return isNumber(n) && !/\./.test(n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expose `fillRange`
|
||||
* @type {Function}
|
||||
*/
|
||||
|
||||
module.exports = fillRange;
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2015, Jon Schlinkert.
|
||||
|
||||
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.
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
# extend-shallow [](http://badge.fury.io/js/extend-shallow) [](https://travis-ci.org/jonschlinkert/extend-shallow)
|
||||
|
||||
> Extend an object with the properties of additional objects. node.js/javascript util.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/)
|
||||
|
||||
```sh
|
||||
$ npm i extend-shallow --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var extend = require('extend-shallow');
|
||||
|
||||
extend({a: 'b'}, {c: 'd'})
|
||||
//=> {a: 'b', c: 'd'}
|
||||
```
|
||||
|
||||
Pass an empty object to shallow clone:
|
||||
|
||||
```js
|
||||
var obj = {};
|
||||
extend(obj, {a: 'b'}, {c: 'd'})
|
||||
//=> {a: 'b', c: 'd'}
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
* [extend-shallow](https://github.com/jonschlinkert/extend-shallow): Extend an object with the properties of additional objects. node.js/javascript util.
|
||||
* [for-own](https://github.com/jonschlinkert/for-own): Iterate over the own enumerable properties of an object, and return an object with properties… [more](https://github.com/jonschlinkert/for-own)
|
||||
* [for-in](https://github.com/jonschlinkert/for-in): Iterate over the own and inherited enumerable properties of an objecte, and return an object… [more](https://github.com/jonschlinkert/for-in)
|
||||
* [is-plain-object](https://github.com/jonschlinkert/is-plain-object): Returns true if an object was created by the `Object` constructor.
|
||||
* [isobject](https://github.com/jonschlinkert/isobject): Returns true if the value is an object and not an array or null.
|
||||
* [kind-of](https://github.com/jonschlinkert/kind-of): Get the native type of a value.
|
||||
|
||||
## Running tests
|
||||
|
||||
Install dev dependencies:
|
||||
|
||||
```sh
|
||||
$ npm i -d && npm test
|
||||
```
|
||||
|
||||
## Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
+ [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
|
||||
|
||||
## License
|
||||
|
||||
Copyright © 2015 Jon Schlinkert
|
||||
Released under the MIT license.
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on June 29, 2015._
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
|
||||
var isObject = require('is-extendable');
|
||||
|
||||
module.exports = function extend(o/*, objects*/) {
|
||||
if (!isObject(o)) { o = {}; }
|
||||
|
||||
var len = arguments.length;
|
||||
for (var i = 1; i < len; i++) {
|
||||
var obj = arguments[i];
|
||||
|
||||
if (isObject(obj)) {
|
||||
assign(o, obj);
|
||||
}
|
||||
}
|
||||
return o;
|
||||
};
|
||||
|
||||
function assign(a, b) {
|
||||
for (var key in b) {
|
||||
if (hasOwn(b, key)) {
|
||||
a[key] = b[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given `key` is an own property of `obj`.
|
||||
*/
|
||||
|
||||
function hasOwn(obj, key) {
|
||||
return Object.prototype.hasOwnProperty.call(obj, key);
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"[email protected]",
|
||||
"C:\\Users\\Administrator\\Documents\\setup-python"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "[email protected]",
|
||||
"_id": "[email protected]",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=",
|
||||
"_location": "/fill-range/extend-shallow",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "[email protected]",
|
||||
"name": "extend-shallow",
|
||||
"escapedName": "extend-shallow",
|
||||
"rawSpec": "2.0.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "2.0.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/fill-range"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
|
||||
"_spec": "2.0.1",
|
||||
"_where": "C:\\Users\\Administrator\\Documents\\setup-python",
|
||||
"author": {
|
||||
"name": "Jon Schlinkert",
|
||||
"url": "https://github.com/jonschlinkert"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/extend-shallow/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"is-extendable": "^0.1.0"
|
||||
},
|
||||
"description": "Extend an object with the properties of additional objects. node.js/javascript util.",
|
||||
"devDependencies": {
|
||||
"array-slice": "^0.2.3",
|
||||
"benchmarked": "^0.1.4",
|
||||
"chalk": "^1.0.0",
|
||||
"for-own": "^0.1.3",
|
||||
"glob": "^5.0.12",
|
||||
"is-plain-object": "^2.0.1",
|
||||
"kind-of": "^2.0.0",
|
||||
"minimist": "^1.1.1",
|
||||
"mocha": "^2.2.5",
|
||||
"should": "^7.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/jonschlinkert/extend-shallow",
|
||||
"keywords": [
|
||||
"assign",
|
||||
"extend",
|
||||
"javascript",
|
||||
"js",
|
||||
"keys",
|
||||
"merge",
|
||||
"obj",
|
||||
"object",
|
||||
"prop",
|
||||
"properties",
|
||||
"property",
|
||||
"props",
|
||||
"shallow",
|
||||
"util",
|
||||
"utility",
|
||||
"utils",
|
||||
"value"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "extend-shallow",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/jonschlinkert/extend-shallow.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"version": "2.0.1"
|
||||
}
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"[email protected]",
|
||||
"C:\\Users\\Administrator\\Documents\\setup-python"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "[email protected]",
|
||||
"_id": "[email protected]",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=",
|
||||
"_location": "/fill-range",
|
||||
"_phantomChildren": {
|
||||
"is-extendable": "0.1.1"
|
||||
},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "[email protected]",
|
||||
"name": "fill-range",
|
||||
"escapedName": "fill-range",
|
||||
"rawSpec": "4.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "4.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/braces"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz",
|
||||
"_spec": "4.0.0",
|
||||
"_where": "C:\\Users\\Administrator\\Documents\\setup-python",
|
||||
"author": {
|
||||
"name": "Jon Schlinkert",
|
||||
"url": "https://github.com/jonschlinkert"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/fill-range/issues"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"email": "[email protected]",
|
||||
"url": "https://github.com/wtgtybhertgeghgtwtg"
|
||||
},
|
||||
{
|
||||
"name": "Edo Rivai",
|
||||
"email": "[email protected]",
|
||||
"url": "edo.rivai.nl"
|
||||
},
|
||||
{
|
||||
"name": "Jon Schlinkert",
|
||||
"email": "[email protected]",
|
||||
"url": "http://twitter.com/jonschlinkert"
|
||||
},
|
||||
{
|
||||
"name": "Paul Miller",
|
||||
"email": "[email protected]",
|
||||
"url": "paulmillr.com"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"extend-shallow": "^2.0.1",
|
||||
"is-number": "^3.0.0",
|
||||
"repeat-string": "^1.6.1",
|
||||
"to-regex-range": "^2.1.0"
|
||||
},
|
||||
"description": "Fill in a range of numbers or letters, optionally passing an increment or `step` to use, or create a regex-compatible range with `options.toRegex`",
|
||||
"devDependencies": {
|
||||
"ansi-cyan": "^0.1.1",
|
||||
"benchmarked": "^1.0.0",
|
||||
"gulp-format-md": "^0.1.12",
|
||||
"minimist": "^1.2.0",
|
||||
"mocha": "^3.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/jonschlinkert/fill-range",
|
||||
"keywords": [
|
||||
"alpha",
|
||||
"alphabetical",
|
||||
"array",
|
||||
"bash",
|
||||
"brace",
|
||||
"expand",
|
||||
"expansion",
|
||||
"fill",
|
||||
"glob",
|
||||
"match",
|
||||
"matches",
|
||||
"matching",
|
||||
"number",
|
||||
"numerical",
|
||||
"range",
|
||||
"ranges",
|
||||
"regex",
|
||||
"sh"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "fill-range",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/jonschlinkert/fill-range.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"verb": {
|
||||
"related": {
|
||||
"list": [
|
||||
"braces",
|
||||
"expand-range",
|
||||
"micromatch",
|
||||
"to-regex-range"
|
||||
]
|
||||
},
|
||||
"toc": true,
|
||||
"layout": "default",
|
||||
"tasks": [
|
||||
"readme"
|
||||
],
|
||||
"plugins": [
|
||||
"gulp-format-md"
|
||||
],
|
||||
"lint": {
|
||||
"reflinks": true
|
||||
}
|
||||
},
|
||||
"version": "4.0.0"
|
||||
}
|
||||
Reference in New Issue
Block a user