Socket
Socket
Sign inDemoInstall

level-supports

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

level-supports - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

test/cloneable.js

16

CHANGELOG.md
# Changelog
## [1.0.1] - 2019-10-13
### Added
- Document format of `additionalMethods` ([`192bc9e`](https://github.com/Level/supports/commit/192bc9e)) ([**@vweevers**](https://github.com/vweevers))
### Fixed
- Clone `additionalMethods` to prevent mutation ([#4](https://github.com/Level/supports/issues/4)) ([**@vweevers**](https://github.com/vweevers))
## 1.0.0 - 2019-09-22
:seedling: Initial release.
[1.0.1]: https://github.com/Level/supports/compare/v1.0.0...v1.0.1

13

index.js

@@ -33,15 +33,4 @@ 'use strict'

// Methods that are not part of abstract-leveldown or levelup
additionalMethods: manifest.additionalMethods || {
// May look something like:
// approximateSize: {
// sync: false,
// callback: true,
// promise: false
// },
// createWriteStream: {
// sync: true,
// writable: true
// }
}
additionalMethods: xtend(manifest.additionalMethods)
})
}
{
"name": "level-supports",
"version": "1.0.0",
"version": "1.0.1",
"description": "Create a manifest describing the abilities of a levelup or abstract-leveldown db",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -164,4 +164,21 @@ # level-supports

Format TBD.
In the form of:
```js
{
foo: true,
bar: true
}
```
Which says the db has two methods, `foo` and `bar`, that are not part of the `abstract-leveldown` interface. It might be used like so:
```js
if (db.supports.additionalMethods.foo) {
db.foo()
}
```
For future extensibility, the properties of `additionalMethods` should be taken as truthy rather than strictly typed booleans. We may add additional metadata (see [#1](https://github.com/Level/supports/issues/1)).
## Install

@@ -168,0 +185,0 @@

@@ -5,2 +5,3 @@ 'use strict'

var shape = require('./shape')
var cloneable = require('./cloneable')

@@ -13,2 +14,3 @@ module.exports = function suite (test, testCommon) {

shape(t, manifest)
cloneable(t, manifest)

@@ -15,0 +17,0 @@ var before = xtend(manifest, {

@@ -6,5 +6,7 @@ 'use strict'

var shape = require('./shape')
var cloneable = require('./cloneable')
test('no options', function (t) {
shape(t, supports())
cloneable(t, supports())
t.end()

@@ -48,7 +50,10 @@ })

var input1 = { bufferKeys: null, streams: false }
var input2 = { streams: true }
var input2 = { streams: true, additionalMethods: {} }
var manifest = supports(input1, input2)
manifest.foobar = true
manifest.additionalMethods.baz = true
t.same(input1, { bufferKeys: null, streams: false })
t.same(input2, { streams: true })
t.same(input2, { streams: true, additionalMethods: {} })
t.is(manifest.bufferKeys, false)

@@ -59,1 +64,15 @@ t.is(manifest.streams, true)

})
test('inherits additionalMethods', function (t) {
var manifest = supports({ additionalMethods: { foo: true } }, {})
t.same(manifest.additionalMethods, { foo: true })
t.end()
})
test('does not merge additionalMethods', function (t) {
var input1 = { additionalMethods: { foo: true } }
var input2 = { additionalMethods: { bar: true } }
var manifest = supports(input1, input2)
t.same(manifest.additionalMethods, { bar: true })
t.end()
})
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