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

expand-range

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expand-range - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

benchmark/check.js

29

.verbrc.md

@@ -38,7 +38,18 @@ # {%= name %} {%= badge("fury") %}

### Custom function
Pass a function as the last argument to customize the expansions:
**Params:**
- `str` the expanded string
- `ch` the [unicode value][unicode] for the string
- `i` the current index
**Example using the `str` value:**
```js
var range = expand('a..e', function (str, i) {
return String.fromCharCode(str) + i;
var range = expand('a..e', function (str, ch, i) {
return str + i;
});

@@ -50,2 +61,13 @@

**Example using the unicode value:**
```js
var range = expand('a..e', function (str, ch, i) {
return String.fromCharCode(ch) + i;
});
console.log(range);
//=> ['a0', 'b1', 'c2', 'd3', 'e4']
```
## Install

@@ -73,1 +95,4 @@ {%= include("install") %}

{%= include("footer") %}
[unicode]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode

2

benchmark/fixtures/alpha-lower.js

@@ -1,1 +0,1 @@

module.exports = 'a..b';
module.exports = 'a..d';

@@ -1,1 +0,1 @@

module.exports = 'A..B';
module.exports = 'A..D';

@@ -44,3 +44,3 @@ /*!

if (typeof special === 'function') {
arr.push(special(i, idx++));
arr.push(special(String.fromCharCode(i), i, idx++));
} else if (typeof special === 'number') {

@@ -47,0 +47,0 @@ arr.push(pad(i, special));

{
"name": "expand-range",
"description": "Expand a range of numbers or letters, uppercase or lowercase. Super fast, see the benchmarks.",
"version": "0.1.0",
"description": "Faster, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. See the benchmarks.",
"version": "0.1.1",
"homepage": "https://github.com/jonschlinkert/expand-range",

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

"brace-expansion": "0.0.0",
"glob": "^4.0.6",
"mocha": "*",

@@ -60,2 +61,2 @@ "should": "^4.1.0",

}
}
}
# expand-range [![NPM version](https://badge.fury.io/js/expand-range.svg)](http://badge.fury.io/js/expand-range)
> Expand a range of numbers or letters, uppercase or lowercase. Super fast, see the benchmarks.
> Faster, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. See the benchmarks.

@@ -38,7 +38,18 @@ ## Benchmarks

### Custom function
Pass a function as the last argument to customize the expansions:
**Params:**
- `str` the expanded string
- `ch` the [unicode value][unicode] for the string
- `i` the current index
**Example using the `str` value:**
```js
var range = expand('a..e', function (str, i) {
return String.fromCharCode(str) + i;
var range = expand('a..e', function (str, ch, i) {
return str + i;
});

@@ -50,2 +61,13 @@

**Example using the unicode value:**
```js
var range = expand('a..e', function (str, ch, i) {
return String.fromCharCode(ch) + i;
});
console.log(range);
//=> ['a0', 'b1', 'c2', 'd3', 'e4']
```
## Install

@@ -80,2 +102,5 @@ #### Install with [npm](npmjs.org):

_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on October 20, 2014._
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on October 25, 2014._
[unicode]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode

@@ -31,8 +31,24 @@ /*!

it('should use a custom function for expansions.', function () {
var range = expand('a..e', function (str, i) {
return String.fromCharCode(str) + i;
describe('when a custom function is used for expansions', function () {
it('should expose the actual character as the first param.', function () {
var range = expand('a..e', function (str, ch, i) {
return str;
});
range.should.eql(['a', 'b', 'c', 'd', 'e']);
});
range.should.eql(['a0', 'b1', 'c2', 'd3', 'e4']);
it('should expose the charCode as the second param.', function () {
var range = expand('a..e', function (str, ch, i) {
return String.fromCharCode(ch);
});
range.should.eql(['a', 'b', 'c', 'd', 'e']);
});
it('should expose the index as the third param.', function () {
var range = expand('a..e', function (str, ch, i) {
return String.fromCharCode(ch) + i;
});
range.should.eql(['a0', 'b1', 'c2', 'd3', 'e4']);
});
});
});
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