Socket
Socket
Sign inDemoInstall

level-packager

Package Overview
Dependencies
Maintainers
4
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

level-packager - npm Package Compare versions

Comparing version 2.0.2 to 2.1.0

10

level-packager.js

@@ -6,6 +6,8 @@ const levelup = require('levelup')

function Level (location, options, callback) {
if (typeof options === 'function')
if (typeof options === 'function') {
callback = options
if (typeof options !== 'object' || options === null)
options = {}
}
if (typeof options !== 'object' || options === null) {
options = {}
}

@@ -23,2 +25,4 @@ return levelup(encode(leveldown(location), options), options, callback)

Level.errors = levelup.errors
return Level

@@ -25,0 +29,0 @@ }

{
"name": "level-packager",
"description": "LevelUP package helper for distributing with a LevelDOWN-compatible back-end",
"version": "2.0.2",
"version": "2.1.0",
"contributors": [

@@ -25,3 +25,3 @@ "Rod Vagg <r@va.gg> (https://github.com/rvagg)",

"scripts": {
"test": "node test.js"
"test": "standard && node test.js"
},

@@ -46,2 +46,3 @@ "homepage": "https://github.com/Level/packager",

"leveldown": "^2.0.0",
"standard": "^10.0.3",
"tape": "^4.0.0"

@@ -48,0 +49,0 @@ },

@@ -10,6 +10,11 @@ # level-packager

[![dependencies](https://david-dm.org/Level/packager.svg)](https://david-dm.org/level/packager)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![npm](https://img.shields.io/npm/dm/level-packager.svg)](https://www.npmjs.com/package/level-packager)
## API
Exports a single function which takes a single argument, an `abstract-leveldown` compatible storage back-end for [`levelup`](https://github.com/Level/levelup). The function returns a constructor function that will bundle `levelup` with the given `abstract-leveldown` replacement. The full API is supported, including optional functions, `destroy()`, and `repair()`. Encoding functionality is provided by [`encoding-down`](https://github.com/Level/encoding-down).
The constructor function has a `.errors` property which provides access to the different error types from [`level-errors`](https://github.com/Level/errors#api).
For example use-cases, see:

@@ -25,4 +30,3 @@

<a name="contributing"></a>
Contributing
------------
## Contributing

@@ -36,4 +40,3 @@ `level-packager` is an **OPEN Open Source Project**. This means that:

<a name="license"></a>
License &amp; Copyright
-------------------
## License &amp; Copyright

@@ -40,0 +43,0 @@ Copyright (c) 2012-2017 `level-packager` [contributors](https://github.com/level/community#contributors).

@@ -1,5 +0,6 @@

const fs = require('fs')
, path = require('path')
'use strict'
var location = path.join(__dirname, 'level-test-' + process.pid + '.db')
const fs = require('fs')
const path = require('path')
const location = path.join(__dirname, 'level-test-' + process.pid + '.db')

@@ -9,2 +10,7 @@ module.exports = function (test, level, options) {

test('Level constructor provides access to levelup errors', function (t) {
t.ok(level.errors, '.errors property set on constructor')
t.end()
})
test('test db open and use, level(location, cb)', function (t) {

@@ -42,3 +48,3 @@ level(location, function (err, db) {

test('test db open and use, db=level(location)', function (t) {
var db = level(location)
const db = level(location)
db.put('test3', 'success', function (err) {

@@ -51,13 +57,11 @@ t.notOk(err, 'no error')

test('test db values', function (t) {
var c = 0
, db = level(location)
, setup = options.nonPersistent
? function (callback) {
db.batch([
{ type: 'put', key: 'test1', value: 'success' }
, { type: 'put', key: 'test2', value: 'success' }
, { type: 'put', key: 'test3', value: 'success' }
], callback)
}
: function (callback) { callback() }
let c = 0
const db = level(location)
const setup = options.nonPersistent ? function (callback) {
db.batch([
{ type: 'put', key: 'test1', value: 'success' },
{ type: 'put', key: 'test2', value: 'success' },
{ type: 'put', key: 'test3', value: 'success' }
], callback)
} : function (callback) { callback() }

@@ -67,4 +71,3 @@ function read (err, value) {

t.equal(value, 'success')
if (++c == 3)
db.close(t.end.bind(t))
if (++c === 3) { db.close(t.end.bind(t)) }
}

@@ -81,5 +84,5 @@

test('options.keyEncoding and options.valueEncoding are passed on to encoding-down', function (t) {
var db = level(location, { keyEncoding: 'json', valueEncoding: 'json' })
const db = level(location, { keyEncoding: 'json', valueEncoding: 'json' })
db.on('ready', function () {
var codec = db.db.codec
const codec = db.db.codec
t.equal(codec.opts.keyEncoding, 'json', 'keyEncoding correct')

@@ -92,5 +95,5 @@ t.equal(codec.opts.valueEncoding, 'json', 'valueEncoding correct')

test('encoding options default to utf8', function (t) {
var db = level(location)
const db = level(location)
db.on('ready', function () {
var codec = db.db.codec
const codec = db.db.codec
t.equal(codec.opts.keyEncoding, 'utf8', 'keyEncoding correct')

@@ -125,7 +128,7 @@ t.equal(codec.opts.valueEncoding, 'utf8', 'valueEncoding correct')

if (!module.parent) {
const test = require('tape')
, packager = require('./')
, leveldown = require('leveldown')
const test = require('tape')
const packager = require('./')
const leveldown = require('leveldown')
module.exports(test, packager(leveldown))
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc