Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

restruct-data

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

restruct-data

ERROR: No README data found!

  • 0.5.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source
  • 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

FAQs

Package last updated on 20 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc