
Research
/Security News
Miasma Mini Shai-Hulud Hits ImmobiliareLabs npm Packages
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.
A cross-brwoser data mapping tool for JavaScript.
It's recommended to install it as dependency.
npm install --save databranch
Download the databranch.min.js file and include it in your HTML.
<script src="path/to/src/databranch.min.js"></script>
var DataBranch = require('databranch');
var data = new DataBranch();
<!--<script src="path/to/src/databranch.min.js"></script>-->
<script>
var data = new DataBranch();
</script>
The examples below will use the functions and variables defined below:
var data = new DataBranch();
var arrInst = new Array(1, 2, 3);
var aNull = null;
Sets a new key-value pair.
key can be anything except undefined. val can be anything.
data.set(document, document.body);
data.set('hello', 'world');
data.set(0, 1);
data.set(arrInst, ['a', 'b', 'c']);
data.set(aNull, null);
/* OR */
// Methods can be chained
data.set(document, document.body).set('hello', 'world').set(...);
DataBranch compares key using .indexOf under the hood. In other words, key must return true using === in order to match.
data.has(document); // true
data.has('hello'); // true
data.has('0'); // false, 0 !== '0'
data.has(arrInst); // true
data.has([1, 2, 3]); // false, arrInst !== [1, 2, 3]
data.has(null); // true, aNull === null
data.get(document); // => <body>...</body>
data.get('hello'); // => 'world'
data.get('0'); // => null
data.get(arrInst); // => ['a', 'b', 'c']
data.get([1, 2, 3]); // => null
data.get(null); // => null
Creates a branch with id identifier.
data.branch(true);
/* Equals to */
data.set(true, new DataBranch());
It returns the newly created branch. Therefore, you can chain methods to it.
data.branch(true).set(false, '!1');
data.get(true).get(false);
// => '!1'
To retrieve branch.
data.of(true).get(false);
// => '!1'
The difference between .of and .get is that .of only gets a branch for you and throw if the branch is not found.
data.of(document);
// => Uncaught TypeError: Value of this ID is not a DataBranch branch.
data.of('nonExistentKey');
// => Uncaught ReferenceError: Branch of this ID does not exist.
data.size
// => 6
data.get(true);
// => DataBranch {...}
data.delete(true);
data.get(true);
// => null
data.size
// => 5
Note: Deleting key/branch will remove all its children data.
data.clear();
data.size;
// => 0
FAQs
A cross-brwoser data mapping tool for JavaScript.
The npm package databranch receives a total of 1 weekly downloads. As such, databranch popularity was classified as not popular.
We found that databranch demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.

Security News
Rolldown paused Rust React Compiler integration after a 5MB binary size increase raised concerns about shipping React-specific code to all Vite users.

Security News
/Research
Mini Shai-Hulud expands into the Go ecosystem after hitting LeoPlatform npm packages and targeting GitHub Actions workflows.