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

baobab

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

baobab - npm Package Compare versions

Comparing version 2.0.0-rc3 to 2.0.0

4

CHANGELOG.md
# Changelog
## v2.0.0 (provisonal)
## v2.0.0

@@ -12,3 +12,3 @@ * The tree is now immutable by default.

* Adding `cursor.exists`.
* Adding `cursor.watch`.
* Adding `tree.watch`.
* Adding the `pure` option.

@@ -15,0 +15,0 @@ * Changing the way you can define computed data in the tree, aka "facets". Facets are now to be defined within the tree itself, are called "monkeys", and can be accessed using the exact same API as normal data.

@@ -87,3 +87,3 @@ /**

// Validation behaviour 'rollback' or 'notify'
// Validation behavior 'rollback' or 'notify'
validationBehavior: 'rollback'

@@ -174,2 +174,7 @@ };

this._refreshMonkeys();
// Initial validation
var validationError = this.validate();
if (validationError) throw Error('Baobab: invalid data.', { error: validationError });
}

@@ -272,2 +277,35 @@

/**
* Method used to validate the tree's data.
*
* @return {boolean} - Is the tree valid?
*/
}, {
key: 'validate',
value: function validate(affectedPaths) {
var _options = this.options;
var validate = _options.validate;
var behavior = _options.validationBehavior;
if (typeof validate !== 'function') return null;
var error = validate.call(this, this._previousData, this._data, affectedPaths || [[]]);
if (error instanceof Error) {
if (behavior === 'rollback') {
this._data = this._previousData;
this._affectedPathsIndex = {};
this._transaction = [];
this._previousData = this._data;
}
this.emit('invalid', { error: error });
return error;
}
return null;
}
/**
* Method used to select data within the tree by creating a cursor. Cursors

@@ -433,23 +471,7 @@ * are kept as singletons by the tree for performance and hygiene reasons.

// Validation?
var _options = this.options;
var validate = _options.validate;
var behavior = _options.validationBehavior;
// Is the tree still valid?
var validationError = this.validate(affectedPaths);
if (typeof validate === 'function') {
var error = validate.call(this, this._previousData, this._data, affectedPaths);
if (validationError) return this;
if (error instanceof Error) {
this.emit('invalid', { error: error });
if (behavior === 'rollback') {
this._data = this._previousData;
this._affectedPathsIndex = {};
this._transaction = [];
this._previousData = this._data;
return this;
}
}
}
// Caching to keep original references before we change them

@@ -562,3 +584,3 @@ var transaction = this._transaction,

Object.defineProperty(Baobab, 'version', {
value: '2.0.0-rc3'
value: '2.0.0'
});

@@ -565,0 +587,0 @@

{
"name": "baobab",
"version": "2.0.0-rc3",
"version": "2.0.0",
"description": "JavaScript persistent data tree with cursors.",

@@ -5,0 +5,0 @@ "main": "./dist/baobab.js",

@@ -51,3 +51,3 @@ /**

// Validation behaviour 'rollback' or 'notify'
// Validation behavior 'rollback' or 'notify'
validationBehavior: 'rollback'

@@ -151,2 +151,8 @@ };

this._refreshMonkeys();
// Initial validation
const validationError = this.validate();
if (validationError)
throw Error('Baobab: invalid data.', {error: validationError});
}

@@ -249,2 +255,37 @@

/**
* Method used to validate the tree's data.
*
* @return {boolean} - Is the tree valid?
*/
validate(affectedPaths) {
const {validate, validationBehavior: behavior} = this.options;
if (typeof validate !== 'function')
return null;
const error = validate.call(
this,
this._previousData,
this._data,
affectedPaths || [[]]
);
if (error instanceof Error) {
if (behavior === 'rollback') {
this._data = this._previousData;
this._affectedPathsIndex = {};
this._transaction = [];
this._previousData = this._data;
}
this.emit('invalid', {error});
return error;
}
return null;
}
/**
* Method used to select data within the tree by creating a cursor. Cursors

@@ -425,26 +466,8 @@ * are kept as singletons by the tree for performance and hygiene reasons.

// Validation?
const {validate, validationBehavior: behavior} = this.options;
// Is the tree still valid?
const validationError = this.validate(affectedPaths);
if (typeof validate === 'function') {
const error = validate.call(
this,
this._previousData,
this._data,
affectedPaths
);
if (validationError)
return this;
if (error instanceof Error) {
this.emit('invalid', {error});
if (behavior === 'rollback') {
this._data = this._previousData;
this._affectedPathsIndex = {};
this._transaction = [];
this._previousData = this._data;
return this;
}
}
}
// Caching to keep original references before we change them

@@ -550,3 +573,3 @@ const transaction = this._transaction,

Object.defineProperty(Baobab, 'version', {
value: '2.0.0-rc3'
value: '2.0.0'
});

@@ -553,0 +576,0 @@

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