Python style slices in JavaScript.
var spice = require('spicejs');
spice('123456789', '2:6'); // '3456'
spice('123456789', '6:2'); // ''
spice('123456789', ':'); // '123456789'
var spice = require('spicejs');
spice([1, 2, 3, 4, 5, 6, 7, 8, 9], '::3'); // [1, 4, 7]
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]
npm install spice
MIT. Copyright (c) Larry Wu