JSPM

@cwola/transactional-object

0.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q10648F
  • License MIT

object transactions.

Package Exports

  • @cwola/transactional-object

Readme

transactional-object

object transactions.

Installation

$ npm i --save @cwola/transactional-object

require / import

  • esm

    import transactionalObject from '@cwola/transactional-object';
  • commonjs

    const transactionalObject = require('@cwola/transactional-object');

Usage

// esm
import createTranObj from '@cwola/transactional-object';

const someValue = createTranObj({
    a: 1,
    b: 2,
    c: [1, 2, 3],
});

// ROLLBACK
console.log(someValue); // { a: 1, b: 2, c: [ 1, 2, 3 ] }
someValue.beginTransaction();
someValue.b = 200;
someValue.x = 42;
someValue.c.push(9);
console.log(someValue); // { a: 1, b: 200, c: [ 1, 2, 3, 9 ], x: 42 }
someValue.rollback();
console.log(someValue); // { a: 1, b: 2, c: [ 1, 2, 3 ] }

// COMMIT
console.log(someValue); // { a: 1, b: 2, c: [ 1, 2, 3 ] }
someValue.beginTransaction();
someValue.b = 200;
someValue.x = 42;
someValue.c.push(9);
console.log(someValue); // { a: 1, b: 200, c: [ 1, 2, 3, 9 ], x: 42 }
someValue.commit();
console.log(someValue); // { a: 1, b: 200, c: [ 1, 2, 3, 9 ], x: 42 }

Reserved word

  • beginTransaction

  • commit

  • rollback

  • inTransaction

License

MIT