Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including inverse-slice with all npm packages installed. Try it out:

var inverseSlice = require("inverse-slice")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

inverse-slice v1.0.3

Use just like slice/splice but it give inversed result

inverse-slice

A small library for inverse slice and splice methods/functions for strings and arrays in node.js

Install

npm: inverse-slice

npm install inverse-slice

Example

Inverse slice (iSlice)

require('inverse-slice');

let arr1 = [1,2,3,4,5,6,7];

let start = 0;
let end = 1;
let arr2 = arr1.iSlice(start, end); // Inverse slice from start to end, will not modify arr1
console.log(arr2);
// -> [2,3,4,5,6,7]
console.log(arr1)
// -> [1,2,3,4,5,6,7] not modified

Api

Just use:

require('inverse-slice');

Slice

Will work with arrays and strings:

Array.iSlice(start, end);
String.iSlice(start, end);
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free