1.0.5 • Published 3 years ago

set-simplified-js v1.0.5

Weekly downloads
15
License
ISC
Repository
github
Last release
3 years ago

set-js

import { Set, SetExtended } from 'set-js';

SetExtended Methods

SetExtended can be used for union and intersection only. In the form

const unionResult = SetExtended.union(s1, s2); const intersectionResult = SetExtended.intersection(s1, s2)

Set Methods

const set = new Set(params); set.add(params); set.has(params); set.delete(params); set.clear(); set.size;

const unionArr = set1.union(set2); const intersectArr = set1.intersection(set2);

params can be ->

  1. array -> 1,2,3
  2. single_element -> 3
  3. elements_comma_separated -> 1,2,3

Methods implemention

  1. How to initiate const s1 = new Set(10,1,2); const s2 = new Set(10,1,2);
  2. Adding elements // .add(params) // return -> nothing s1.add([3,4,5]); s1.add(0,1,2); s1.add(0);
  3. Check for element existance // .has(params) // return -> true(if all elements are present) || false(if any elements is not present) s1.has(10,0) // true (all elements present) s1.has(100) // false s1.has(10,0) // true (all elements present)
  4. Delete element or elements // .delete(params) // return -> true(if any one is present and deleted) || false(if any one is present and deleted) s1.delete([10, 500, [[80]]]) // true s1.delete(10, 500) // false (10 already deleted and 500 not present so none of these present) s1.delete(10) // false s1.has(10) // false
  5. Clear all elements // .clear() // return -> nothing s1.clear()
  6. Get total number of elements present // .size // return -> number s1.size
  7. Union of two sets // .union(set2) const arr = s1.union(s2)
  8. Intersection of two sets // .intersection(set2) const arr1 = s1.intersection(s2)
1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago