Comparing version 0.0.6 to 0.0.7
{ | ||
"name": "json-rel", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "Transparent references in JSON", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -60,9 +60,7 @@ # json-rel | ||
```javascript | ||
import query from 'json-rel' | ||
import path from 'json-rel' | ||
import pointer from 'json-rel' | ||
import {query, path, pointer} from 'json-rel' | ||
let query1 = query('foo[bar]', data).get() // true | ||
let path2 = path('$.foo.bar', data).get() // true | ||
let pointer2 = pointer('/foo/bar', data).get() // true | ||
query('foo[bar]', data).get() // true | ||
path('$.foo.bar', data).get() // true | ||
pointer('/foo/bar', data).get() // true | ||
``` | ||
@@ -69,0 +67,0 @@ |
@@ -39,2 +39,16 @@ export const _specs = {} | ||
count(obj = this.value) { | ||
const results = this.get(obj) | ||
if (results instanceof Array) { | ||
return results.length | ||
} | ||
return results ? 1 : 0 | ||
} | ||
any(obj = this.value) { | ||
return !!this.count(obj) | ||
} | ||
set(obj = this.value, data) { | ||
@@ -41,0 +55,0 @@ return this.spec.update(this.path, obj, data) |
import 'blanket' | ||
import {$, which, AbstractRel, AbstractRelSpec} from '../src/abstract' | ||
import PathRelSpec from '../src/path' | ||
@@ -11,3 +12,24 @@ import chai from 'chai' | ||
describe('AbstractRel', () => { | ||
it('should prevent initialization of abstract members if a spec is not provided', () => { | ||
// FIXME | ||
// (() => { | ||
// new AbstractRel | ||
// }).should.throw(TypeError) | ||
(() => { | ||
new AbstractRel({spec: PathRelSpec}) | ||
}).should.not.throw(TypeError) | ||
}) | ||
}) | ||
describe('AbstractRelSpec', () => { | ||
it('should prevent initialization of abstract members', () => { | ||
(() => { | ||
new AbstractRelSpec() | ||
}).should.throw(TypeError) | ||
}) | ||
@@ -14,0 +36,0 @@ it('should be able to identify arbitrary relations', () => { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13470
267
75