All Projects → terkelg → Zet

terkelg / Zet

Licence: mit
Set() as it should be.

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Zet

BruteSniffing Fisher
hacking tool
Stars: ✭ 24 (-94.95%)
Mutual labels:  set
NonEmptyCollections
A type-safe implementation for collections that cannot be empty. Life is too short for emptiness-checks!
Stars: ✭ 45 (-90.53%)
Mutual labels:  set
Javascript Datastructures Algorithms
📚 collection of JavaScript and TypeScript data structures and algorithms for education purposes. Source code bundle of JavaScript algorithms and data structures book
Stars: ✭ 3,221 (+578.11%)
Mutual labels:  set
php-sorted-collections
Sorted Collections for PHP
Stars: ✭ 22 (-95.37%)
Mutual labels:  set
observable ish
Observable state and events for browser and Flutter.
Stars: ✭ 26 (-94.53%)
Mutual labels:  set
BurgerCustomArmor
Create Custom Armor Sets with several abilities!
Stars: ✭ 25 (-94.74%)
Mutual labels:  set
rab
Rusty Armor Builds - Monster Hunter Rise Armor Set Creation Tool
Stars: ✭ 29 (-93.89%)
Mutual labels:  set
Mlib
Library of generic and type safe containers in pure C language (C99 or C11) for a wide collection of container (comparable to the C++ STL).
Stars: ✭ 321 (-32.42%)
Mutual labels:  set
set-config-resolver
[READ-ONLY] Loads configs to you with CLI --config, -c, --set, -s or sets parameter
Stars: ✭ 50 (-89.47%)
Mutual labels:  set
Gostl
Data structure and algorithm library for go, designed to provide functions similar to C++ STL
Stars: ✭ 254 (-46.53%)
Mutual labels:  set
activerecord-setops
Union, Intersect, and Difference set operations for ActiveRecord (also, SQL's UnionAll).
Stars: ✭ 21 (-95.58%)
Mutual labels:  set
unikmer
Toolkit for k-mer with taxonomic information
Stars: ✭ 46 (-90.32%)
Mutual labels:  set
invokable
Objects are functions! Treat any Object or Class as a Proc (like Enumerable but for Procs).
Stars: ✭ 40 (-91.58%)
Mutual labels:  set
ctl
My variant of the C Template Library
Stars: ✭ 105 (-77.89%)
Mutual labels:  set
Kind Of
Get the native JavaScript type of a value, fast. Used by superstruct, micromatch and many others!
Stars: ✭ 268 (-43.58%)
Mutual labels:  set
MHArmory
Armor Set Search application for Monster Hunter: World
Stars: ✭ 20 (-95.79%)
Mutual labels:  set
setprotocol.js
🥞 Javascript library for a collateralized basket of ERC20 tokens
Stars: ✭ 57 (-88%)
Mutual labels:  set
Php Enum
Simple and fast implementation of enumerations with native PHP
Stars: ✭ 446 (-6.11%)
Mutual labels:  set
Redisson
Redisson - Redis Java client with features of In-Memory Data Grid. Over 50 Redis based Java objects and services: Set, Multimap, SortedSet, Map, List, Queue, Deque, Semaphore, Lock, AtomicLong, Map Reduce, Publish / Subscribe, Bloom filter, Spring Cache, Tomcat, Scheduler, JCache API, Hibernate, MyBatis, RPC, local cache ...
Stars: ✭ 17,972 (+3683.58%)
Mutual labels:  set
js-collections-map-set
Repository to have example code to demonstrate JavaScript Map and Set data structures.
Stars: ✭ 21 (-95.58%)
Mutual labels:  set

zet

version build status codecov install size

JavaScript Set() as it should be.

ECMAScript 6 sets have no methods for computing the union (∪), intersection (∩) or difference (⊖). Zet is an extension of ES6 Set and comes with all its functionality included with extra set logic. The API is similar to how sets work in Python.

Features

Additions to the default ECMAScript 6 set

  • Union (∪)
  • Intersection (∩)
  • Difference/subtract (-)
  • Symmetric difference (⊖)
  • Subset (⊆)
  • Superset (⊇)
  • Map
  • Filter
  • Reduce

Additionally, this module is delivered as:

  • ES Module: dist/zet.mjs
  • CommonJS: dist/zet.js
  • UMD: dist/zet.umd.js

Install

$ npm install --save zet

Usage

import Zet from 'zet';

let a = new Zet([1, 2, 3]);
let b = new Zet([3, 4, 5]);
let c = new Zet([2, 3, 4]);

Zet.union(a, b);
//=> [Zet] {1, 2, 3, 4, 5}

a.union(b, c);
//=> [Zet] {1, 2, 3, 4, 5}

a.intersection(b);
//=> [Zet] {3}

a.symmetricDifference(c);
//=> [Zet] {1, 4}

a.subset(b);
//=> false

a.filter(i => i % 2);
//=> [Zet] {1, 3}

API

Zet([iterable])

Returns:Zet

Returns the Zet instance.

Zet extends Set() and inherit all its functionality, like has(), size() etc.

Zet.union(...sets) ∪

Returns:zet

Static variadic function that return a new set with elements from all other sets.

sets

Type: Zet|Set

Two or more sets of type Zet or Set.

Zet.intersection(...sets) ∩

Returns:zet

Static variadic function that return a new set with elements common to this and all other sets.

sets

Type: Zet|Set

Two or more sets of type Zet or Set.

Zet.difference(...sets) - or \

Returns:zet

Returns the difference between two or more sets. The order of the sets matters. Sets are differentiated against the first argument/set.

sets

Type: Zet|Set

Two or more sets of type Zet or Set.

Zet.symmetricDifference(setA, setB) ⊖ or ∆

Returns:zet

Static function that return a new set with elements in either setA or setB but not both.

setA

Type: Zet|Set

Set A of type Zet or Set.

setB

Type: Zet|Set

Set B of type Zet or Set.

Zet.subset(setA, setB)

Returns: Boolean

Test whether every element in setB is in setA.

setA

Type: Zet|Set

Set of type Zet or Set.

setB

Type: Zet|Set

Set of type Zet or Set.

Zet.superset(setA, setB)

Returns: Boolean

Test whether every element in setA is in setB.

setA

Type: Zet|Set

Set of type Zet or Set.

setB

Type: Zet|Set

Set of type Zet or Set.

map(set, func)

Returns: Zet|Set

Creates a set with the results of calling the provided function on every element.

set

Type: Zet|Set

Set of type Zet or Set.

func

Type: Function

Function that produces an element of the new set.

filter(set, func)

Returns: Zet|Set

Creates a set with all elements that pass the test implemented by the provided function.

set

Type: Zet|Set It is the set going to be examined.

func

Type: Function

It is a predicate, to test each element of the set.

reduce(set, func, initializer)

Returns: Number

Reduces the set to a single value, by executing the provided function for each element in the set (from left-to-right).

set

Type: Zet|Set

Set of type Zet or Set.

func

Type: Function

Function to be executed for each element in the set.

initializer

Type: Number

Optional. A value to be passed to the function as the initial value.

Instance Methods

union(...sets) ∪

Returns:zet

Variadic method that return a new set with elements from this and all other sets.

sets

Type: Zet|Set

One or more sets of type Zet or Set.

intersection(...sets) ∩

Returns:zet

Variadic method that return a new set with elements common to this and all other sets.

sets

Type: Zet|Set

One or more sets of type Zet or Set.

difference(...sets) - or \

Returns:zet

Variadic method tht return a new set with elements in this that are not in the other sets.

sets

Type: Zet|Set

One or more sets of type Zet or Set.

symmetricDifference(other) ⊖ or ∆

Returns:zet

Method that return a new set with elements in either this or other but not both. This is also known as xor.

other

Type: Zet|Set

Set of type Zet or Set.

subset(other)

Returns: Boolean

Test whether every element in the set is in other.

other

Type: Zet|Set

Set of type Zet or Set.

superset(other)

Returns: Boolean

Test whether every element in other is in the set.

other

Type: Zet|Set

Set of type Zet or Set.

map(func)

Returns: Zet|Set

Creates a set with the results of calling the provided function on every element.

func

Type: Function

Function that produces an element of the new set.

filter(func)

Returns: Zet|Set

Creates a set with all elements that pass the test implemented by the provided function.

func

Type: Function

It is a predicate, to test each element of the set.

reduce(func, initializer)

Returns: Number

Reduces the set to a single value, by executing the provided function for each element in the set (from left-to-right).

func

Type: Function

Function to be executed for each element in the set.

initializer

Type: Number

Optional. A value to be passed to the function as the initial value.

License

MIT © Terkel Gjervig

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].