Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fill-range

Package Overview
Dependencies
Maintainers
4
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fill-range - npm Package Compare versions

Comparing version 5.0.0 to 6.0.0

89

index.js
/*!
* fill-range <https://github.com/jonschlinkert/fill-range>
*
* Copyright (c) 2014-2017, Jon Schlinkert.
* Copyright (c) 2014-present, Jon Schlinkert.
* Released under the MIT License.

@@ -10,7 +10,5 @@ */

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');
const util = require('util');
const isNumber = require('is-number');
const toRegex = require('to-regex-range');

@@ -28,9 +26,9 @@ /**

function fillRange(start, stop, step, options) {
if (typeof start === 'undefined') {
if (start === void 0) {
return [];
}
if (typeof stop === 'undefined' || start === stop) {
if (stop === void 0 || start === stop) {
// special case, for handling negative zero
var isString = typeof start === 'string';
let isString = typeof start === 'string';
if (isNumber(start) && !toNumber(start)) {

@@ -51,3 +49,3 @@ return [isString ? '0' : 0];

var opts = extend({step: step}, options);
const opts = Object.assign({ step }, options);
if (opts.step && !isValidNumber(opts.step)) {

@@ -69,7 +67,8 @@ if (opts.strictRanges === true) {

opts.isPadded = isPadded(start) || isPadded(stop);
opts.toString = opts.stringify
|| typeof opts.step === 'string'
|| typeof start === 'string'
|| typeof stop === 'string'
|| !opts.isNumber;
opts.toString =
opts.stringify ||
typeof opts.step === 'string' ||
typeof start === 'string' ||
typeof stop === 'string' ||
!opts.isNumber;

@@ -87,6 +86,6 @@ if (opts.isPadded) {

function expand(start, stop, options) {
var a = options.isNumber ? toNumber(start) : start.charCodeAt(0);
var b = options.isNumber ? toNumber(stop) : stop.charCodeAt(0);
let a = options.isNumber ? toNumber(start) : start.charCodeAt(0);
let b = options.isNumber ? toNumber(stop) : stop.charCodeAt(0);
var step = Math.abs(toNumber(options.step)) || 1;
let step = Math.abs(toNumber(options.step)) || 1;
if (options.toRegex && step === 1) {

@@ -96,9 +95,16 @@ 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;
let zero = { greater: [], lesser: [] };
let asc = a < b;
let arr = new Array(Math.round((asc ? b - a : a - b) / step));
let idx = 0;
if (!asc && options.strictOrder) {
if (options.strictRanges === true) {
throw new RangeError('invalid range arguments: ' + util.inspect([start, stop]));
}
return [];
}
while (asc ? a <= b : a >= b) {
var val = options.isNumber ? a : String.fromCharCode(a);
let val = options.isNumber ? a : String.fromCharCode(a);
if (options.toRegex && (val >= 0 || !options.isNumber)) {

@@ -129,2 +135,6 @@ zero.greater.push(val);

}
if (options.limit > 0 && arr.length >= options.limit) {
break;
}
}

@@ -147,21 +157,22 @@

var start = String.fromCharCode(Math.min(a, b));
var stop = String.fromCharCode(Math.max(a, b));
return '[' + start + '-' + stop + ']';
start = String.fromCharCode(Math.min(a, b));
stop = String.fromCharCode(Math.max(a, b));
return `[${start}-${stop}]`;
}
function toSequence(arr, zeros, options) {
var greater = '', lesser = '';
let greater = '';
let lesser = '';
if (zeros.greater.length) {
greater = zeros.greater.join('|');
}
if (zeros.lesser.length) {
lesser = '-(' + zeros.lesser.join('|') + ')';
lesser = `-(${zeros.lesser.join('|')})`;
}
var res = greater && lesser
? greater + '|' + lesser
: greater || lesser;
let res = greater && lesser ? `${greater}|${lesser}` : greater || lesser;
if (options.capture) {
return '(' + res + ')';
return `(${res})`;
}

@@ -173,5 +184,5 @@ return res;

if (options.isPadded) {
var str = String(val);
var len = str.length;
var dash = '';
let str = String(val);
let len = str.length;
let dash = '';
if (str.charAt(0) === '-') {

@@ -181,5 +192,5 @@ dash = '-';

}
var diff = options.maxLength - len;
var pad = repeat('0', diff);
val = (dash + pad + str);
let diff = options.maxLength - len;
let pad = '0'.repeat(diff);
val = dash + pad + str;
}

@@ -202,3 +213,3 @@ if (options.stringify) {

return (isValidNumber(min) || isValidLetter(min))
&& (isValidNumber(max) || isValidLetter(max));
&& (isValidNumber(max) || isValidLetter(max));
}

@@ -205,0 +216,0 @@

{
"name": "fill-range",
"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`",
"version": "5.0.0",
"version": "6.0.0",
"homepage": "https://github.com/jonschlinkert/fill-range",

@@ -24,3 +24,3 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

"engines": {
"node": ">=0.10.0"
"node": ">=4.0"
},

@@ -31,13 +31,11 @@ "scripts": {

"dependencies": {
"extend-shallow": "^2.0.1",
"is-number": "^4.0.0",
"repeat-string": "^1.6.1",
"to-regex-range": "^2.1.1"
"is-number": "^7.0.0",
"to-regex-range": "^4.0.1"
},
"devDependencies": {
"ansi-cyan": "^0.1.1",
"benchmarked": "^2.0.0",
"gulp-format-md": "^1.0.0",
"minimist": "^1.2.0",
"mocha": "^3.5.0"
"mocha": "^3.5.3",
"write": "^1.0.3"
},

@@ -44,0 +42,0 @@ "keywords": [

@@ -236,6 +236,7 @@ # fill-range [![NPM version](https://img.shields.io/npm/v/fill-range.svg?style=flat)](https://www.npmjs.com/package/fill-range) [![NPM monthly downloads](https://img.shields.io/npm/dm/fill-range.svg?style=flat)](https://npmjs.org/package/fill-range) [![NPM total downloads](https://img.shields.io/npm/dt/fill-range.svg?style=flat)](https://npmjs.org/package/fill-range) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/fill-range.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/fill-range)

| --- | --- |
| 108 | [jonschlinkert](https://github.com/jonschlinkert) |
| 111 | [jonschlinkert](https://github.com/jonschlinkert) |
| 2 | [paulmillr](https://github.com/paulmillr) |
| 2 | [realityking](https://github.com/realityking) |
| 2 | [bluelovers](https://github.com/bluelovers) |
| 1 | [edorivai](https://github.com/edorivai) |
| 1 | [realityking](https://github.com/realityking) |
| 1 | [wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg) |

@@ -247,8 +248,9 @@

* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
* [GitHub Profile](https://github.com/jonschlinkert)
* [Twitter Profile](https://twitter.com/jonschlinkert)
### License
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).

@@ -258,2 +260,2 @@

_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on November 01, 2017._
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on July 05, 2018._

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc