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

fill-range

Package Overview
Dependencies
Maintainers
1
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 1.7.1 to 1.8.0

34

index.js

@@ -10,2 +10,3 @@ /*!

var isObject = require('isobject');
var isNumber = require('is-number');

@@ -32,3 +33,3 @@ var randomize = require('randomatic');

function fillRange(a, b, step, fn) {
function fillRange(a, b, step, options, fn) {
if (a == null || b == null) {

@@ -39,10 +40,19 @@ throw new Error('fill-range expects the first and second args to be strings.');

if (typeof step === 'function') {
fn = step; step = null;
fn = step; options = {}; step = null;
}
if (typeof options === 'function') {
fn = options; options = {};
}
if (isObject(step)) {
options = step; step = '';
}
var expand, regex = false, sep = '';
var opts = options || {};
step = step || opts.step;
// store a ref to unmodified arg
var origA = a;
var origB = b;
var origA = a, origB = b;

@@ -54,15 +64,17 @@ b = (b.toString() === '-0') ? 0 : b;

var match = stepRe().exec(step);
if (match) {
var i = match.index;
var m = match[0];
// repeat string
if (match[0] === '+') {
if (m === '+') {
return repeat(a, b);
// randomize a, `b` times
} else if (match[0] === '?') {
} else if (m === '?') {
return [randomize(a, b)];
// expand right, no regex reduction
} else if (match[0] === '>') {
} else if (m === '>') {
step = step.substr(0, i) + step.substr(i + 1);

@@ -73,15 +85,15 @@ expand = true;

// string for a regex logic `or`
} else if (match[0] === '|') {
} else if (m === '|') {
step = step.substr(0, i) + step.substr(i + 1);
expand = true;
regex = true;
sep = match[0];
sep = m;
// expand to an array, or if valid create a reduced
// string for a regex range
} else if (match[0] === '~') {
} else if (m === '~') {
step = step.substr(0, i) + step.substr(i + 1);
expand = true;
regex = true;
sep = match[0];
sep = m;
}

@@ -88,0 +100,0 @@ } else if (!isNumber(step)) {

{
"name": "fill-range",
"description": "Fill in a range of numbers or letters, optionally passing an increment or multiplier to use.",
"version": "1.7.1",
"version": "1.8.0",
"homepage": "https://github.com/jonschlinkert/fill-range",

@@ -33,2 +33,3 @@ "author": {

"is-number": "^1.1.0",
"isobject": "^0.2.0",
"randomatic": "^1.0.1",

@@ -35,0 +36,0 @@ "repeat-element": "^1.0.0",

@@ -175,2 +175,9 @@ # fill-range [![NPM version](https://badge.fury.io/js/fill-range.svg)](http://badge.fury.io/js/fill-range)

## Related
- [micromatch]: wildcard/glob matcher for javascript. a faster alternative to minimatch.
- [expand-range]: uses fill-range for range expansion in strings
- [braces]: uses expand range to do range expansion in glob patterns and braces.
## Contributing

@@ -192,4 +199,8 @@ Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/fill-range/issues)

_This file was generated by [verb](https://github.com/assemble/verb) on January 24, 2015._
_This file was generated by [verb](https://github.com/assemble/verb) on January 25, 2015._
[randomatic]: https://github.com/jonschlinkert/randomatic
[randomatic]: https://github.com/jonschlinkert/randomatic
[expand-range]: https://github.com/jonschlinkert/expand-range
[micromatch]: https://github.com/jonschlinkert/micromatch
[braces]: https://github.com/jonschlinkert/braces
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