Skip to content

A fine collection of collection-classes and utilities written in CoffeScript.

Notifications You must be signed in to change notification settings

jbysewski/coffee-collection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Coffee-CollectionBuild Status

A fine collection of collection-classes and utilities written in CoffeScript. Intended for Node- and client-side usage.

Currently contains

  • Set - each entry is singular, no duplicates allowed
  • Map - stores "entries" for provided "keys" like a dictionary
  • Graph - a set of nodes where each node max be conected with other nodes making a path

API

  • Set
    • !Important! If an element has an .equals-method it is used to determine if other items are treated as the same - otherwise the is-operator (===) is used
    • add element: Adds an element if it is not already contained
    • addAll ['a', 'b'] | otherSet: adds all elements from an array or other set
    • remove element: Removes an element
    • removeAll ['a', 'b'] | otherSet: removes all elements from an array or other set
    • clear(): Removes all elements
    • size(): Returns the number of elements contained in this set
    • isEmtpy(): Returns true if this set is empty
    • has element: Returns true if element.equals other returns true for any other element or - if element does not have a method equals - if an contained element is equal in terms of (===)

Examples

Set

fruit = new Set
fruit.add 'Apple'
fruit.add 'Banana'
fruit.add 'Cherry'
fruit.size() # => 3

fruit.add 'Apple' # adding the same entry twice
fruit.size() # => 3

fruit.has 'Cherry' # => true
fruit.has 'Raspberry' # => false

fruit.elements() # => ['Apple', 'Banana', 'Cherry']

About

A fine collection of collection-classes and utilities written in CoffeScript.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published