Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "json-rel", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Transparent data references in JSON", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -50,1 +50,3 @@ import jsonPath from 'jsonpath' | ||
export const $ = () => new PathRel(...arguments) | ||
export default {PathRel, PathRelSpec, $} |
@@ -45,1 +45,3 @@ import jsonPointer from 'jsonpointer' | ||
export const _ = () => new PointerRel(...arguments) | ||
export default {PointerRel, PointerRelSpec, _} |
import jsonQuery from 'json-query' | ||
import {AbstractRel, AbstractRelSpec} from './abstract' | ||
export class QueryRel extends AbstractRel { | ||
constructor(path, value) { | ||
super({ path, value, spec: new QueryRelSpec() }) | ||
this.path = path | ||
this.value = value | ||
} | ||
} | ||
export class QueryRelSpec extends AbstractRelSpec { | ||
@@ -11,3 +21,3 @@ | ||
matches(rel) { | ||
if (!rel.constructor === String && !rel.constructor === Array) { | ||
if (!rel.constructor === String && !rel instanceof Array) { | ||
return false | ||
@@ -19,2 +29,14 @@ } | ||
follow(rel, data) { | ||
if (this.matches(rel)) { | ||
return jsonQuery(rel, {data}).value || [] | ||
} | ||
} | ||
update(rel, obj, data) { | ||
// TODO - no core support | ||
} | ||
} | ||
export const ø = () => new QueryRel(...arguments) |
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
9135
13
192