My toolset of day a day, in a simple library.
Made with love ❤️
npm install --save raj
let array1 = [1, 2, 3, 4];
let array2 = [3, 4, 5, 6];
let diff = raj.diff(array1, array2);
console.log(diff);
// [ 1, 2, 5, 6 ]
let arrayBase = [1, 2, 3, 4];
let arrayComparator = [3, 4, 5, 6];
let diff = raj.diffBase(arrayBase, arrayComparator)
console.log(diff);
// [ 1, 2 ]
let arr1 = [1, 2, 3, 4];
let arr2 = [4, 5, 6];
let common = raj.common(arr1, arr2);
console.log(common);
// [ 4 ]
let array = [5, 5, 10, 30];
let sum = raj.sumArray(array);
console.log(sum);
// 50
let array = [5, 5, 10, 30];
let rand = raj.randItem(array);
console.log(rand);
// 5...
This sh*t save my life on batch parallel processing
let array = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17];
let numberOfItems = 5;
let batch = raj.split(array, numberOfItems);
console.log(batch);
// [ [ 1, 2, 3, 4, 5 ],
// [ 6, 7, 8, 9, 10 ],
// [ 11, 12, 13, 14, 15 ],
// [ 16, 17 ] ]
Coming soon...
const object = {
name: 'hello',
id: 3123423,
lorem: 'ipsum',
music: 'hello darkness my old friend',
raj: 'http://awesome'
}
raj.selectFromObject(object, ['name', 'id']) // {name: 'hello', id: 3123423}
const result = raj.isString('hello');
const string = 'hello'
const number = 12321
raj.isString(string); // true
raj.isString(number); // false
const string = 'hello';
const object = {a:1};
raj.isObject(string); // false
raj.isObject(object); // true
const string = 'hello'
const number = 12321
raj.isNumber(string); // false
raj.isNumber(number); // true
const string = "Hello";
const object = {
hello: "value"
};
const array = [1, 2, 3];
raj.isArray(string); //false
raj.isArray(object); //false
raj.isArray(array); //true