
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
Class providing dot path syntax for properties, JSON serialization, singletons and more.
Class providing dot path syntax for properties, JSON serialization, singletons and more.
You can pass several objects and will be merged recursively.
const obj = new jfObject(
{
a : {
b : 0
c : 2
}
},
{
a : {
b : 1,
}
},
{
a : {
c : 3
}
}
);
console.log(obj.toJSON()); // { a : { b : 1, c : 3 } }
You can use dot notation in order to assign/retrieve/test nested objects.
const obj = new jfObject();
obj.set('d.e.f', 5);
console.log(obj.toJSON()); // { d : { e : { f : 5 } } }
console.log(obj.get('d.e')); // { f : 5 }
console.log(obj.has('d.e.f')); // true
Objects can be merged in 2 ways:
obj.merge(...).Object.assign(obj, ...)const obj = new jfObject(
{
a : {
b : 0
}
}
);
// Recursive merge
obj.merge(
{
a : {
c : 1
}
}
);
console.log(obj.toJSON()); // { a : { b : 0, c : 1 } }
// Overwrite merge
Object.assign(
obj,
{
a : {
c : 2
}
}
);
console.log(obj.toJSON()); // { a : { c : 2 } }
You can use new ES6 loop for..of:
const obj = new jfObject(
{
a : 1,
c : 2,
f : 3,
h : 4
}
);
for (const prop of obj)
{
console.log('%s = %s', prop, obj[prop]);
}
// a = 1
// c = 2
// f = 3
// h = 4
If you need to split object into keys and values, you can use split or toArray methods.
const obj = new jfObject(
{
a : 1,
c : 2,
f : 3,
h : 4
}
);
console.log(obj.split()); // { keys: [ 'a', 'c', 'f', 'h' ], values: [ 1, 2, 3, 4 ] }
console.log(obj.toArray()); // [ [ 'a', 1 ], [ 'c', 2 ], [ 'f', 3 ], [ 'h', 4 ] ]
If you need to share the same instance between differents external modules,
you can use static method i() in order to retrieve the same instance
anywhere in the app.
class User extends jfObject
{
// User class methods and properties
}
// Initialize the User instance on ajax response using external library:
function onAjaxResponse(data)
{
//...
User.i().setProperties(data);
//...
}
// In UI, using external framework
<user-info data="{{User.i()}}" />
FAQs
Class providing dot path syntax for properties, JSON serialization, singletons and more.
The npm package @jf/object receives a total of 1 weekly downloads. As such, @jf/object popularity was classified as not popular.
We found that @jf/object demonstrated a healthy version release cadence and project activity because the last version was released less than 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.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.