
Research
/Security News
Malicious npm Packages Target WhatsApp Developers with Remote Kill Switch
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
The simplest high performance local JSON database.
$ npm i niodb --save
The following code creates a Nio database on an empty .json file example_data.json
, and adds some key-value pairs to it.
import { Nio } from 'niodb' // OR const { Nio } = require('niodb')
const db = await new Nio('example_data.json')
db.name = 'NioDB'
db.message = 'Hello NioDB!'
db.users = {
count: 100
}
db.users.count++
The example_data.json
file after running this code is going to be:
{
"name": "NioDB",
"message": "Hello NioDB!",
"users": {
"count": 101
}
}
Setting a key in the database to hold a value is like assigning a value to a JavaScript object:
import { Nio } from 'niodb'
const db = await new Nio()
db.key = 'value'
If filepath
is defined, changes to the data will be stored on disk asynchronously and atomically.
Getting the value of a key is also very simple:
console.log(db.key)
🌟 Just think of the Nio instance as a normal JavaScript object.
Alternatively, you can use wrapper methods $set
and $get
to do the same thing:
db.$set(key, value)
db.$get(key)
The choice is yours.
Just like deleting and checking for keys in JavaScript objects:
delete db.key
console.log(key in db)
db.$delete(key)
db.$exists(key)
new Nio(filepath, config)
:Each Nio instance is a database binding to a .json file:
const database = await new Nio(filepath, config);
If filepath
is a string, new Nio(filepath)
returns a Promise object that will return a Nio instance, so await
must be used to get the instance.
If filepath
is not defined, it will return a Nio instance, so no await
is needed. However, for consistency, you should always use await
when initializing the database.
config
is optional, it should be an object.
All options are:
await new Nio(filepath, {
// this method is called when the .json file on your disk has been updated
transactionUpdated: () => {}
})
All wrapper methods are:
$set(key, value)
: Set the value of a key. Setting the value to undefined
will lead to a TypeError
.$get(key)
: Get the value of a key.$delete(key)
: Delete a key.$exists(key)
: Return if a key exists.$randomKey()
: Return a random key.$rename(key, newKey)
: Rename key to newKey, replacing the new key if it already exists.$type(key)
: Return the data type of the value stored in key. Possible return values are: array
, object
, null
, number
, string
, boolean
, and undefined
.You can chain together wrapper methods:
const db = await new Nio()
db.content = {
content1: 'hello',
content2: 'this is NioDB',
content3: 'you will like it'
}
db.content.$delete('content1').$rename('content2', 'introduction').$set('content3', true)
console.log(db)
You will get:
{
content: {
content3: true,
introduction: 'this is NioDB'
}
}
import { DatabaseError } from 'niodb'
$ npm test
$ npm build
FAQs
The simplest local JSON database
We found that niodb 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
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
Research
/Security News
Socket uncovered 11 malicious Go packages using obfuscated loaders to fetch and execute second-stage payloads via C2 domains.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.