spicejs
v0.0.1
Published
Python style slices in JavaScript.
Downloads
5
Readme
Spice
Python style slices in JavaScript.
Code Example
Basic usage
var spice = require('spicejs');
spice('123456789', '2:6'); // '3456'
spice('123456789', '6:2'); // ''
spice('123456789', ':'); // '123456789'
Extended syntax
var spice = require('spicejs');
spice([1, 2, 3, 4, 5, 6, 7, 8, 9], '::3'); // [1, 4, 7]
Extending native objects
var spice = require('spicejs');
if (!Array.prototype.spice) {
Array.prototype.spice = function(slice) {
return spice(this, slice);
}
}
[1, 2, 4, 5, 6].spice('2:5') // [3, 4, 5]
Installation
npm install spice
License
MIT. Copyright (c) Larry Wu