Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
originally a fork of nathan7/level-promise
Promisified level API with Q
$ npm install q-level
At the application level, promises vs callbacks is yours to choose. If you use this in a LevelUp extension that isn't explicitly about promises, nathan7 will find you and destroy you. Play nice with the rest, use callbacks for your extension. If your extension works with level-manifest, it'll work with this.
Every method marked as async by level-manifest will now return a promise when you don't pass it a callback. The methods that return readable streams will return streams augmented with Q's promise interface.
It recurses into sublevels.
var level = require('level')
var promisify = require('q-level')
var db = promisify(level('my.db', { valueEncoding: 'json' }))
var contents = {}
db.put('a', 1)
.then(function() {
return db.batch([
{ type: 'put', key: 'b', value: 2 },
{ type: 'put', key: 'c', value: 3 }
])
})
.then(function() {
return db.createReadStream()
})
.progress(function(data) {
contents[data.key] = data.value
})
.catch(function(err) {
console.log('Error reading stream', err)
})
.then(function() {
console.log('Contents:', contents)
return db.close()
})
.done(function() {
console.log('Closed')
})
same example as above, but with callbacks
var level = require('level')
var promisify = require('q-level')
var db = promisify(level('my.db'), { valueEncoding: 'json' })
var contents = {}
db.put('a', 1, function(err) {
db.batch([
{ type: 'put', key: 'b', value: 2 },
{ type: 'put', key: 'c', value: 3 }
], function(err) {
return db.createReadStream()
.on('data', function(data) {
contents[data.key] = data.value
})
.on('error', function(err) {
console.log('Error reading stream', err)
})
.on('close', function(err) {
console.log('Contents:', contents)
db.close(function(err) {
console.log('Closed')
})
})
})
})
var level = require('level')
var levelQuery = require('level-queryengine')
var jsonQueryEngine = require('jsonquery-engine')
var promisify = require('q-level')
db = levelQuery(level('my.db', { valueEncoding: 'json' }))
db.query.use(jsonQueryEngine())
// IMPORTANT TO PROMISIFY LAST!
promisify(db)
promisify(db, 'query', { type: 'readable' })
db.query({ happy: { $in: ['very', 'not so much'] }})
.progress(function(val) {
// do stuff
})
.done(function() {
// do other stuff
})
MIT
FAQs
Promise'd LevelUp with Q, originally a fork of nathan7/level-promise.
The npm package q-level receives a total of 2 weekly downloads. As such, q-level popularity was classified as not popular.
We found that q-level demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.