
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Tu ne cede malis sed contra audentior ito.
Safely set
, get
and remove
any property, in any object.
Say goodbye to those (ugly and unfriendly) undefined
exceptions and having to probe multiple properties to get what you actually want. Let salvus
handle it for you.
The default usage, require('salvus')
, will bind salvus
to your application's objects as a prototype, making it available everywhere.
npm install --save salvus
require('salvus');
const soldier = {
name: 'Persephone',
age: 23
};
soldier.lego('name');
// Persephone
soldier.lego('contact.address.city');
// undefined
soldier.noto('contact.address.city:Rome');
// soldier is now
// {
name: 'Persephone',
age: 23,
contact: {
address: {
city: 'Rome'
}
}
}
soldier.noto(['wars.fought:100', 'wars.won:97']);
// soldier is now
// {
name: 'Persephone',
age: 23,
contact: {
address: {
city: 'Rome'
}
},
wars: {
fought: 100,
won: 97
}
}
{}.noto(string || array)
- The property to be written and it's value. Provide an array if setting multiple properties at once.
{}.lego(property [, refer, strict, identifier])
- The property to read.
refer
(boolean) Identify undefined properties. Default: false
.strict
(boolean) Only return set values. Default: false
.identifier
(string) Prepend a custom identifier to undefined properties (refer
must be set to true
). Default: !!
.{}.erado(string || array)
- Properties to delete.
{}.purgo()
- Purge the object: ''
, undefined
, null
, {}
and []
will be removed.
cons salvus = require('salvus/lib/io');
const soldier = {
name: 'Persephone',
age: 23
};
salvus.lego(soldier, 'name');
// Persephone
salvus.lego(soldier, 'contact.address.city');
// undefined
salvus.noto(soldier, 'contact.address.city:Rome');
// soldier is now
// {
name: 'Persephone',
age: 23,
contact: {
address: {
city: 'Rome'
}
}
}
salvus.noto(soldier, ['wars.fought:100', 'wars.won:97']);
// soldier is now
// {
name: 'Persephone',
age: 23,
contact: {
address: {
city: 'Rome'
}
},
wars: {
fought: 100,
won: 97
}
}
salvus.noto(object, string || array)
- The property to be written and it's value. Provide an array if setting multiple properties at once.
salvus.lego(object, property [, refer, strict, identifier])
- The property to read.
refer
(boolean) Identify undefined properties. Default: false
.strict
(boolean) Only return set values. Default: false
.identifier
(string) Prepend a custom identifier to undefined properties (refer
must be set to true
). Default: !!
.salvus.erado(object string || array)
- Properties to delete.
salvus.purgo(object)
- Purge the object: ''
, undefined
, null
, {}
and []
will be removed.
The object
parameter always represents the object being operated on.
Take a look at the tests; tests/index.js
and tests/io.js
.
fork https://github.com/aichholzer/salvus/
Silentium est aureum.
FAQs
Safely set, get and delete any property in any object.
We found that salvus 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.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.