0.5.2 • Published 7 years ago

restruct-data v0.5.2

Weekly downloads
13
License
-
Repository
github
Last release
7 years ago
  • Usage

** Basic

#+BEGIN_SRC javascript var restruct = require('restruct-data');

var struct = restruct.structure({ "Hello": "< text" });

var result = struct({ text: "World" });

// result = { "Hello": "World!" }; #+END_SRC

** Frame

#+BEGIN_SRC javascript var Restruct = require('restruct-data');

var restruct = Restruct();

restruct.method('frame_info', function() { if (this.index === 0) { this.index // 0 this.data // { "id": 1, "name": "Chuck Norris" }

       // 'this.data' is the same as 'this.source[this.index]'

       this.parent		// parent Frame( [ { "id": 1, ...}, { "id": 2, ...} ] )
       this.source()	// "this.parent.data" but returns null if no parent

       this.keys()		// [ 'id', 'name' ]
       this.values()	// [ 1, 'Chuck Norris' ]
       this.child('id')	// Frame(1)
       this.child('name')	// Frame('Chuck Norris')
       this.children()	// [ Frame(1), Frame('Chuck Norris') ]

       this.restruct	// restruct instance
       this.restruct.root	// root Frame(...), which would be 'this.parent' in this case
   }

});

var collection = restruct.collection( { "id": 1, "name": "Chuck Norris" },{ "id": 2, "name": "Robin Williams" } );

var result = collection.format({ "< id": "= frame_info()" }); #+END_SRC

0.5.2

7 years ago

0.5.1

7 years ago

0.5.0

7 years ago

0.4.0

7 years ago

0.3.5

8 years ago

0.3.4

8 years ago

0.3.3

8 years ago

0.3.2

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.10

8 years ago

0.2.9

8 years ago

0.2.8

9 years ago

0.2.7

9 years ago

0.2.6

9 years ago

0.2.5

9 years ago

0.2.4

9 years ago

0.2.3

9 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.10

9 years ago

0.1.9

9 years ago

0.1.8

9 years ago

0.1.7

9 years ago

0.1.6

9 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago