0.1.1 • Published 10 years ago

eventual-schema v0.1.1

Weekly downloads
19
License
-
Repository
github
Last release
10 years ago

eventual-schema

Build Status

Combine multiple objects into a record of property counts. Apply rules to describe when and how to freeze the result into a generalised schema of accepted properties.

Note

This was made for express-keenio and therefore the interfaces and data structure provided match what is expected by this. I might later on try to record other information into the structure and to allow it to generate schemas that could be used by some popular ORMs or request validators.

I've also heard that there has been academic research into this topic, but I could not for the life of me find it so I just created something fit for my purposes and nothing further.

Usage

var EventualSchema = require('eventual-schema');

var eventualSchema = new EventualSchema([function (ctx) { return this._instanceCount >= 5; }]);

console.log(eventualSchema.frozen);
// => false

eventualSchema.add({ a: { b: 7 }, c: 9 });
eventualSchema.add({ a: { b: 7 }, c: 9 });
eventualSchema.add({ a: { b: 7 }, c: 9 });
eventualSchema.add({ a: { b: 7 }, c: 9 });
eventualSchema.add({ a: { b: 7 }, c: 9 });

console.log(eventualSchema.frozen);
// => true

console.log(eventualSchema.get());
// =>
// { a: { _propertyCount: 5, b: { _propertyCount: 5 } }, c: { _propertyCount: 5 } }
0.1.1

10 years ago

0.1.0

10 years ago

0.0.5

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago