@tpluscode/rdfine
Advanced tools
Comparing version 0.2.5 to 0.2.6
@@ -5,2 +5,9 @@ # Changelog | ||
### [0.2.6](https://github.com/tpluscode/rdfine/compare/v0.2.5...v0.2.6) (2020-01-21) | ||
### Features | ||
* setter proxy ([e2f11fb](https://github.com/tpluscode/rdfine/commit/e2f11fbb335d0a9ac6c84b92f7bf4b6165aea230)) | ||
### [0.2.5](https://github.com/tpluscode/rdfine/compare/v0.2.4...v0.2.5) (2020-01-20) | ||
@@ -7,0 +14,0 @@ |
@@ -1,2 +0,2 @@ | ||
import rdf from 'rdf-data-model'; | ||
import rdf from '@rdfjs/data-model'; | ||
import { xsd } from './vocabs'; | ||
@@ -3,0 +3,0 @@ const trueLiteral = rdf.literal('true', xsd.boolean); |
import { fromLiteral } from '../../conversion'; | ||
import { xsd } from '../../vocabs'; | ||
import rdf from 'rdf-data-model'; | ||
import rdf from '@rdfjs/data-model'; | ||
import { propertyDecorator } from '../property'; | ||
@@ -5,0 +5,0 @@ const trueLiteral = rdf.literal('true', xsd.boolean); |
@@ -1,2 +0,2 @@ | ||
import { namedNode } from 'rdf-data-model'; | ||
import { namedNode } from '@rdfjs/data-model'; | ||
function namespacedPredicate(term, namespace) { | ||
@@ -3,0 +3,0 @@ if (!namespace) { |
@@ -24,3 +24,29 @@ import { fromResource } from './conversion'; | ||
}, | ||
set(target, property, value) { | ||
if (property in target) { | ||
target[property.toString()] = value; | ||
return true; | ||
} | ||
if (typeof property === 'number') { | ||
return false; | ||
} | ||
const values = Array.isArray(value) ? value : [value]; | ||
const valueNodes = values | ||
.reduce((values, value) => { | ||
if (!value || typeof value !== 'object') { | ||
return values; | ||
} | ||
if (value && 'termType' in value) { | ||
return [...values, value]; | ||
} | ||
return [...values, value.id]; | ||
}, []); | ||
const predicate = target._node.namedNode(property.toString()); | ||
target._node.deleteOut(predicate); | ||
if (values.length) { | ||
target._node.addOut(predicate, valueNodes); | ||
} | ||
return true; | ||
}, | ||
}); | ||
} |
import { rdf } from './vocabs'; | ||
import { namedNode } from 'rdf-data-model'; | ||
import { namedNode } from '@rdfjs/data-model'; | ||
function getNode(value) { | ||
@@ -4,0 +4,0 @@ if (typeof value === 'string') { |
@@ -6,5 +6,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const rdf_data_model_1 = __importDefault(require("rdf-data-model")); | ||
const data_model_1 = __importDefault(require("@rdfjs/data-model")); | ||
const vocabs_1 = require("./vocabs"); | ||
const trueLiteral = rdf_data_model_1.default.literal('true', vocabs_1.xsd.boolean); | ||
const trueLiteral = data_model_1.default.literal('true', vocabs_1.xsd.boolean); | ||
function fromLiteral(type, obj) { | ||
@@ -11,0 +11,0 @@ if (type === Boolean) { |
@@ -8,5 +8,5 @@ "use strict"; | ||
const vocabs_1 = require("../../vocabs"); | ||
const rdf_data_model_1 = __importDefault(require("rdf-data-model")); | ||
const data_model_1 = __importDefault(require("@rdfjs/data-model")); | ||
const property_1 = require("../property"); | ||
const trueLiteral = rdf_data_model_1.default.literal('true', vocabs_1.xsd.boolean); | ||
const trueLiteral = data_model_1.default.literal('true', vocabs_1.xsd.boolean); | ||
function default_1(options = {}) { | ||
@@ -28,3 +28,3 @@ const type = options.type || String; | ||
} | ||
return rdf_data_model_1.default.literal(value.toString(), datatype); | ||
return data_model_1.default.literal(value.toString(), datatype); | ||
}, valueTypeName: type.name, assertSetValue: (value) => { | ||
@@ -31,0 +31,0 @@ return typeof value !== 'object' || value.termType === 'Literal'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const rdf_data_model_1 = require("rdf-data-model"); | ||
const data_model_1 = require("@rdfjs/data-model"); | ||
function namespacedPredicate(term, namespace) { | ||
@@ -13,3 +13,3 @@ if (!namespace) { | ||
if (termOrString.match(/^(http|urn):\/\//)) { | ||
return rdf_data_model_1.namedNode(termOrString); | ||
return data_model_1.namedNode(termOrString); | ||
} | ||
@@ -16,0 +16,0 @@ return namespacedPredicate(termOrString, namespace); |
@@ -26,4 +26,30 @@ "use strict"; | ||
}, | ||
set(target, property, value) { | ||
if (property in target) { | ||
target[property.toString()] = value; | ||
return true; | ||
} | ||
if (typeof property === 'number') { | ||
return false; | ||
} | ||
const values = Array.isArray(value) ? value : [value]; | ||
const valueNodes = values | ||
.reduce((values, value) => { | ||
if (!value || typeof value !== 'object') { | ||
return values; | ||
} | ||
if (value && 'termType' in value) { | ||
return [...values, value]; | ||
} | ||
return [...values, value.id]; | ||
}, []); | ||
const predicate = target._node.namedNode(property.toString()); | ||
target._node.deleteOut(predicate); | ||
if (values.length) { | ||
target._node.addOut(predicate, valueNodes); | ||
} | ||
return true; | ||
}, | ||
}); | ||
} | ||
exports.createProxy = createProxy; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const vocabs_1 = require("./vocabs"); | ||
const rdf_data_model_1 = require("rdf-data-model"); | ||
const data_model_1 = require("@rdfjs/data-model"); | ||
function getNode(value) { | ||
if (typeof value === 'string') { | ||
return rdf_data_model_1.namedNode(value); | ||
return data_model_1.namedNode(value); | ||
} | ||
@@ -9,0 +9,0 @@ if ('termType' in value) { |
{ | ||
"name": "@tpluscode/rdfine", | ||
"version": "0.2.5", | ||
"version": "0.2.6", | ||
"description": "RDF/JS idiomatic, native, enjoyable", | ||
@@ -28,3 +28,3 @@ "main": "dist/node/index.js", | ||
"clownface": "^0.12.1", | ||
"rdf-data-model": "^1.0.0", | ||
"@rdfjs/data-model": "^1.1.2", | ||
"once": "^1.4.0", | ||
@@ -51,3 +51,2 @@ "@types/clownface": "^0.12.4", | ||
"@types/rdfjs__parser-n3": "^1.1.2", | ||
"@types/rdf-data-model": "^1.0.2", | ||
"@typescript-eslint/eslint-plugin": "^2.12.0", | ||
@@ -54,0 +53,0 @@ "@typescript-eslint/parser": "^2.12.0", |
@@ -149,3 +149,3 @@ ## RDFine _/rɪdɪˈfaɪn/_ | ||
[ | ||
"@babel/proposal-class-properties" | ||
"@babel/plugin-proposal-class-properties" | ||
] | ||
@@ -152,0 +152,0 @@ ] |
Sorry, the diff of this file is not supported yet
71118
32
1198
+ Added@rdfjs/data-model@^1.1.2
- Removedrdf-data-model@^1.0.0
- Removedrdf-data-model@1.0.0(transitive)