DailyJS

Syphon, json-schema-benchmark

Alex R. Young

Subscribe

@dailyjs

Facebook

Google+

libraries JSON node modules react json-schema

Syphon, json-schema-benchmark

Posted by Alex R. Young on .
Featured

libraries JSON node modules react json-schema

Syphon, json-schema-benchmark

Posted by Alex R. Young on .

Syphon

Syphon (GitHub: scttnlsn/syphon, License: MIT, npm: syphon) by Scott Nelson is an implementation of the Flux architectural pattern for React. It helps you to structure applications around a single immutable state value, and implements the dispatching of actions to various state-transitioning handler functions.

The application's state is stored in an immutable data structure that you create with the atom method. To access a value, you deref it, and you can also modify it by using swap:

var state = syphon.atom({ foo: 'bar' });

state.swap(function(current) {  
  console.log(current.toJS());

  return current.set('foo', 'baz');
});

console.log(state.deref().toJS());  
// => { foo: 'baz' }

Responding to state changes involves writing handlers, which takes the form of functions with two arguments: value and currentState. The application's state is available in the second argument.

Syphon's author recommends using the multimethod module to deal with handlers that branch on multiple values.

Syphon includes the root method for mounting your component hierarchy, and a mixin for adding helpers to components for accessing application data and dispatch values.

json-schema-benchmark

I may need to create some JSON schemas in the near future, so it was fortunate that Allan Ebdrup sent in json-schema-benchmark. This is a benchmark for JSON schema validators, and covers the following modules:

It also shows test failures when run against the official JSON Schema Test Suite. One cool addition is a summary of tests that caused side-effects, so you can see which validators altered values.