Infinite Object (Io) - Version control tree using plain JavaScript and prototypical inheritance
Infinite Object minimal version: minimal.js
Minimal proof of concept api:
{ "use strict"; // Declare Io POC { thistree = ; } Ioprototype { var up = Object; thistree; uptree = ; return up; }; // Create version tree var root = ; // Set values in root rootkey = "value"; rootkey2 = objects: "work" ; // Make a new branch using up() var branch = root; // Prototypical inheritance console; console; // Set value in branch branchkey = "value2"; // Version tree can be traversed from root console; // Properties are inherited from parent console; // Branches override values console;};
Infinite Object small version: small_polyfilled.js
Still small but slightly more usable api with polyfill to work in ES3
/*global io*/var root = ; // Allows creating branch using objectroot; // Version tree found in root.branches instead of root.tree
Infinite Object UMD (Universal Module Definition) / main (Node.js) / browser version: main.umd.js
Proper api, requires ES5
{ // Root and branches are immutable (frozen with Object.freeze) and thus // all properties are non-configurable and non-writable after creation var root = ; var infiniteWhiteSpaceCollection = root; var branch1 = root; var branch2 = root; var branch21 = branch2; // var reservedPropertyNames = ["branch", "branches", "version"]; // Version tree found in root.branches instead of root.tree console; // Branches have a version number console; console; // The root (and thus branches) has a reference to the current branch console; console; var branch11 = branch1; var branch211 = branch21; // Branch changes on branching console; // The root (and thus branches) has a reference to the root console; console; { // Called with branch when current branch changes console; } var off = root; // Change version to parent branch rootcurrentBranch = Object; root; // Or call return value of on to unsubscribe ; // root.view === branchN.view contains an Object without prototype [Object.create(null)] which has all // the properties from the prototype chain (excluding root) of the currently active branch. // Enabling fast existence checking of and access to the current properties, // without repeated prototype chain traversal. var view = rootview; var key; for key in view console; for key in branch21 console; // Every branch has a timestamp console; // Can de/serialize from/to JSON var jsonIo = JSON; var parsedIo = io; var reStringified = JSON; console; var jsonArr = documentinnerHTML = JSON; var parsedArr = JSON; console;};
Infinite Object ECMAScript 5 module / jsnext:main (deprecated package.json property, use module) version: main.es5.js
Proper api, requires ES5+
;var root = ;
Infinite Object ECMAScript module es2015 version: main.js
Proper api, requires ES2015+ / ES6+ / ES latest, uses Proxy api for immutable branches/array behavior
; // Root and branches are immutable (frozen with Object.freeze) and thus// all properties are non-configurable and non-writable after creationconst root = ;const infiniteWhiteSpaceCollection = root;const branch1 = root;const branch2 = root;const branch21 = branch2;// var reservedPropertyNames = ["branch", "branches", "version"]; // Version tree found in root.branches instead of root.treeconsole; // Branches have a version numberconsole;console; // The root (and thus branches) has a reference to the current branchconsole;console; const branch11 = branch1;const branch211 = branch21; // Branch changes on branchingconsole; // The root (and thus branches) has a reference to the rootconsole;console; { // Called with branch when current branch changes console;} const off = root; // Change version to parent branchrootcurrentBranch = Object; root; // Or call return value of on to unsubscribe; // root.view === branchN.view contains an Object without prototype [Object.create(null)] which has all// the properties from the prototype chain (excluding view and branches) of the currently active branch.// Enabling fast existence checking of and access to the current properties,// without repeated prototype chain traversal.const view = rootview;let key;for key in view console;for key in branch21 console; // Every branch has a timestampconsole; // Can de/serialize from/to JSONconst jsonIo = JSON;const parsedIo = io;const reStringified = JSON;console; const jsonArr = documentinnerHTML = JSON; const parsedArr = JSON; console;