Skip to content

monolithed/Tuples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

Tuple

Coverage Status

Implementation of object Tuple

Element access

  • get ( [ String name ] );
tuple.get('key');

Capacity

  • Number size ( );
tuple.size();
  • Boolean empty ( );
tuple.empty();

Modifiers

  • Function set ( );
var tuple = new Tuple;

tuple.set('a', 1)
         ('b', 2)
         ('c', 3)
;
  • Function add ( );
tuple.add('d', 4)
         ('e', 5)
;
  • void tie ( );
tuple.tie(tuple2);
  • &remove ( );
tuple.remove('b');
  • void clear ( );
tuple.clear();

Examples

    1. Get and set fields
var tuple = new Tuple;

tuple.set('a', 0)(1, 2)('function', function(param) {
	alert(param);
});

tuple.get('a');           // 0
tuple.get('function')(1); // 1
tuple.get(1);             // 2
tuple.get();              // {a: 1, 'function': [ object Function ], 1: 2}
    1. Add or modify fields
var tuple = new Tuple;

tuple.set('a', 1)
         ('b', 2)
;

tuple.add('c', 3)
         ('d', 4)
;

tuple.add(1, 5);

tuple.get(); // {a: 1, b: 2, c: 3, d: 4, 1: 5}
    1. // Tie fields
var tuple1 = new Tuple;
var tuple2 = new Tuple;

tuple1.set('a', 1);
tuple2.set('b', 2)

tuple1.tie(tuple2);
// tuple1: {a: 1, b: 2}
    1. Remove fields
var tuple = new Tuple;

tuple.set('a', 1)
         ('b', 2)
         ('c', 3)
;

tuple.remove('a');
// tuple: {b: 2, c: 3}
    1. Get size of fields
var tuple = new Tuple;

tuple.set('a', 1)
         ('b', 2)
         ('c', 3)
;

tuple.size(); // 3
    1. Clear the fields
var tuple = new Tuple;

tuple.set('a', 1)
         ('b', 2)
         ('c', 3)
;

tuple.clear(); // true
tuple.size();  // 0
    1. Tie
var tuple1 = new Tuple;
tuple1.set('a', 0)

var tuple2 = new Tuple;
tuple2.set('b', 1);

tuple1.tie(tuple2);

tuple1.get('b'); // 1

##_

  • License This work is licensed under the MIT license

About

Implementation of object Tuple

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published