Utils
About
a project contain simple javaScript functions to do something like merge arrays, remove duplicates elements, ...
Features & Functions
- removeDuplicates
- merge
- removeTwins
- removeFromArray
- toggleArrayValue
Documentation
Install
npm install @mohssineAboutaj/utils
or
yarn add @mohssineAboutaj/utils
Usage
Usage of removeDuplicates()
const { removeDuplicates } = require("@mohssineAboutaj/utils");
let origin = [1, 2, 3, 4, 5, 6];
let removes = [1, 3, 2, 6];
let arr = removeDuplicates(origin, removes);
console.log(arr); // output is [4,5]
Usage of removeTwins()
const { removeTwins } = require("@mohssineAboutaj/utils");
let origin = [1, 2, 3, 4, 5, 6];
let removes = [1, 3, 2, 6]; // not required
let arr = removeTwins(origin, removes);
console.log(arr); // output is [4,5]
Usage of merge()
const { merge } = require("@mohssineAboutaj/utils");
let arr = merge([1, 2, 3], [4, 5, 6], "a", { b: 1 }, null, true, undefined, 20);
console.log(arr); // output is [1, 2, 3, 4, 5, 6, 'a', { b: 1 }, null, true, undefined, 20]
Usage of removeFromArray()
const { removeFromArray } = require("@mohssineAboutaj/utils");
let origin = [1, 2, 3, 4, 5, 6];
let removes = 2; // not required
let arr = removeFromArray(origin, removes);
console.log(arr); // output is [1,3,4,5,6]
Usage of toggleArrayValue()
const { toggleArrayValue } = require("@mohssineAboutaj/utils");
let origin = ["a", "b", "c"];
let value = 2; // not required
let arr = toggleArrayValue(origin, value);
console.log(arr); // output is ['a','b','c',2]
Changelog
read more about changing in changelog file
License
MIT