New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

ldflex

Package Overview
Dependencies
Maintainers
2
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ldflex - npm Package Compare versions

Comparing version
2.12.2
to
2.13.0
+76
lib/CollectionsHandler.js
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.collectionHandler = collectionHandler;
exports.containerHandler = containerHandler;
exports.listHandler = listHandler;
var _handlerUtil = require("./handlerUtil");
const RDF = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#';
/**
* @returns An handler that returns an RDF list as an array
*/
function listHandler() {
return (0, _handlerUtil.handler)((_, path) => async () => {
let _path = await path;
const list = [];
while (_path && _path.value !== `${RDF}nil`) {
list.push(_path[`${RDF}first`]);
_path = await _path[`${RDF}rest`];
}
return (await Promise.all(list)).filter(value => value !== undefined);
});
}
/**
* @param {Boolean} set Emits set if True, array otherwise
* @returns An handler that returns an RDF collection as an array or set
*/
function containerHandler(set) {
return (0, _handlerUtil.handler)((_, path) => async () => {
let container = [];
let elem;
let count = 0; // eslint-disable-next-line no-cond-assign
while (elem = await path[`${RDF}_${++count}`]) container.push(elem);
container = await Promise.all(container);
return set ? new Set(container) : container;
});
}
/**
* @returns An handler that returns an RDF collection according to its RDF:type
*/
function collectionHandler() {
return (0, _handlerUtil.handler)((pathData, path) => async () => {
var _await$path$;
// TODO: Handle cases where multiple classes may be present (e.g. if inferencing is on)
switch ((_await$path$ = await path[`${RDF}type`]) === null || _await$path$ === void 0 ? void 0 : _await$path$.value) {
case `${RDF}List`:
return listHandler().handle(pathData, path)();
case `${RDF}Bag`:
return containerHandler(true).handle(pathData, path)();
case `${RDF}Alt`:
case `${RDF}Seq`:
case `${RDF}Container`:
return containerHandler(false).handle(pathData, path)();
default:
// In this case none of the appropriate containers apply
return path;
}
});
}
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.handler = handler;
// Creates a handler from the given function
function handler(handle) {
return {
handle
};
}
import { handler } from './handlerUtil';
const RDF = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#';
/**
* @returns An handler that returns an RDF list as an array
*/
export function listHandler() {
return handler((_, path) => async () => {
let _path = await path;
const list = [];
while (_path && _path.value !== `${RDF}nil`) {
list.push(_path[`${RDF}first`]);
_path = await _path[`${RDF}rest`];
}
return (await Promise.all(list)).filter(value => value !== undefined);
});
}
/**
* @param {Boolean} set Emits set if True, array otherwise
* @returns An handler that returns an RDF collection as an array or set
*/
export function containerHandler(set) {
return handler((_, path) => async () => {
let container = [];
let elem;
let count = 0; // eslint-disable-next-line no-cond-assign
while (elem = await path[`${RDF}_${++count}`]) container.push(elem);
container = await Promise.all(container);
return set ? new Set(container) : container;
});
}
/**
* @returns An handler that returns an RDF collection according to its RDF:type
*/
export function collectionHandler() {
return handler((pathData, path) => async () => {
var _await$path$;
// TODO: Handle cases where multiple classes may be present (e.g. if inferencing is on)
switch ((_await$path$ = await path[`${RDF}type`]) === null || _await$path$ === void 0 ? void 0 : _await$path$.value) {
case `${RDF}List`:
return listHandler().handle(pathData, path)();
case `${RDF}Bag`:
return containerHandler(true).handle(pathData, path)();
case `${RDF}Alt`:
case `${RDF}Seq`:
case `${RDF}Container`:
return containerHandler(false).handle(pathData, path)();
default:
// In this case none of the appropriate containers apply
return path;
}
});
}
// Creates a handler from the given function
export function handler(handle) {
return {
handle
};
}
import { handler } from './handlerUtil';
const RDF = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#';
/**
* @returns An handler that returns an RDF list as an array
*/
export function listHandler() {
return handler((_, path) => async () => {
let _path = await path;
const list = [];
while (_path && _path.value !== `${RDF}nil`) {
list.push(_path[`${RDF}first`]);
_path = await _path[`${RDF}rest`];
}
return (await Promise.all(list)).filter(value => value !== undefined);
});
}
/**
* @param {Boolean} set Emits set if True, array otherwise
* @returns An handler that returns an RDF collection as an array or set
*/
export function containerHandler(set) {
return handler((_, path) => async () => {
let container = [];
let elem;
let count = 0;
// eslint-disable-next-line no-cond-assign
while (elem = await path[`${RDF}_${++count}`])
container.push(elem);
container = await Promise.all(container);
return set ? new Set(container) : container;
});
}
/**
* @returns An handler that returns an RDF collection according to its RDF:type
*/
export function collectionHandler() {
return handler((pathData, path) => async () => {
// TODO: Handle cases where multiple classes may be present (e.g. if inferencing is on)
switch ((await path[`${RDF}type`])?.value) {
case `${RDF}List`:
return listHandler().handle(pathData, path)();
case `${RDF}Bag`:
return containerHandler(true).handle(pathData, path)();
case `${RDF}Alt`:
case `${RDF}Seq`:
case `${RDF}Container`:
return containerHandler(false).handle(pathData, path)();
default:
// In this case none of the appropriate containers apply
return path;
}
});
}
// Creates a handler from the given function
export function handler(handle) {
return { handle };
}
+16
-14

@@ -10,2 +10,4 @@ "use strict";

var _CollectionsHandler = require("./CollectionsHandler");
var _DataHandler = _interopRequireDefault(require("./DataHandler"));

@@ -53,2 +55,4 @@

var _handlerUtil = require("./handlerUtil");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -65,2 +69,7 @@

[Symbol.asyncIterator]: new _AsyncIteratorHandler.default(),
// Add utilities for collections
list: (0, _CollectionsHandler.listHandler)(),
container: (0, _CollectionsHandler.containerHandler)(false),
containerAsSet: (0, _CollectionsHandler.containerHandler)(true),
collection: (0, _CollectionsHandler.collectionHandler)(),
// Add read and query functionality

@@ -97,19 +106,12 @@ get: new _GetFunctionHandler.default(),

toArray: new _ToArrayHandler.default(),
termTypes: handler((_, path) => path.toArray(term => term.termType)),
values: handler((_, path) => path.toArray(term => term.value)),
datatypes: handler((_, path) => path.toArray(term => term.datatype)),
languages: handler((_, path) => path.toArray(term => term.language)),
termTypes: (0, _handlerUtil.handler)((_, path) => path.toArray(term => term.termType)),
values: (0, _handlerUtil.handler)((_, path) => path.toArray(term => term.value)),
datatypes: (0, _handlerUtil.handler)((_, path) => path.toArray(term => term.datatype)),
languages: (0, _handlerUtil.handler)((_, path) => path.toArray(term => term.language)),
// Parse a string into an LDflex object
resolve: new _StringToLDflexHandler.default()
}; // Creates a handler from the given function
}; // Creates a handler for the given RDF/JS Term property
exports.default = _default;
function handler(handle) {
return {
handle
};
} // Creates a handler for the given RDF/JS Term property
function termPropertyHandler(property) {

@@ -119,3 +121,3 @@ // If a resolved subject is present,

// otherwise, return a promise to the property value
return handler((_ref, path) => {
return (0, _handlerUtil.handler)((_ref, path) => {
let {

@@ -130,3 +132,3 @@ subject

function subjectToPrimitiveHandler() {
return handler(_ref2 => {
return (0, _handlerUtil.handler)(_ref2 => {
let {

@@ -133,0 +135,0 @@ subject

import AsyncIteratorHandler from './AsyncIteratorHandler';
import { listHandler, containerHandler, collectionHandler } from './CollectionsHandler';
import DataHandler from './DataHandler';

@@ -23,2 +24,3 @@ import DeleteFunctionHandler from './DeleteFunctionHandler';

import { termToPrimitive } from './valueUtils';
import { handler } from './handlerUtil';
/**

@@ -34,2 +36,7 @@ * A map with default property handlers.

[Symbol.asyncIterator]: new AsyncIteratorHandler(),
// Add utilities for collections
list: listHandler(),
container: containerHandler(false),
containerAsSet: containerHandler(true),
collection: collectionHandler(),
// Add read and query functionality

@@ -72,11 +79,4 @@ get: new GetHandler(),

resolve: new StringToLDflexHandler()
}; // Creates a handler from the given function
}; // Creates a handler for the given RDF/JS Term property
function handler(handle) {
return {
handle
};
} // Creates a handler for the given RDF/JS Term property
function termPropertyHandler(property) {

@@ -83,0 +83,0 @@ // If a resolved subject is present,

{
"name": "ldflex",
"version": "2.12.2",
"version": "2.13.0",
"description": "A JavaScript DSL for querying Linked Data on the Web",

@@ -34,2 +34,4 @@ "license": "MIT",

"@babel/preset-env": "^7.16.4",
"@comunica/actor-init-sparql-file": "^1.22.3",
"@ldflex/comunica": "^3.5.0",
"eslint": "^8.4.0",

@@ -39,2 +41,3 @@ "eslint-plugin-jest": "^25.3.0",

"jest": "^27.4.3",
"n3": "^1.12.2",
"semantic-release": "^18.0.1"

@@ -41,0 +44,0 @@ },

@@ -142,2 +142,38 @@ # LDflex makes Linked Data in JavaScript fun

### Accessing collections
Handle `rdf:List`, `rdf:Bag`, `rdf:Alt`, `rdf:Seq` and `rdf:Container`.
For `rdf:List`s
```javascript
(async publication => {
// Returns an Array of Authors
const authors = await publication['bibo:authorList'].list();
})(ordonez_medellin_2014);
```
For `rdf:Alt`, `rdf:Seq` and `rdf:Container`s
```javascript
(async data => {
// Returns an Array of elements
const elements = await data['ex:myContainer'].container();
})(data);
```
For `rdf:Bag`s
```javascript
(async data => {
// Returns a Set of elements
const elements = await data['ex:myBag'].containerAsSet();
})(data);
```
Alternatively, `.collection` can be used for *any* collection (i.e. `rdf:List`, `rdf:Bag`, `rdf:Alt`, `rdf:Seq` and `rdf:Container`) **provided the collection has the correct `rdf:type` annotation in the data source**
```javascript
(async publication => {
// Returns an Array of Authors
const authors = await publication['bibo:authorList'].collection();
})(ordonez_medellin_2014);
```
## Additional Handlers

@@ -144,0 +180,0 @@

import AsyncIteratorHandler from './AsyncIteratorHandler';
import { listHandler, containerHandler, collectionHandler } from './CollectionsHandler';
import DataHandler from './DataHandler';

@@ -23,2 +24,3 @@ import DeleteFunctionHandler from './DeleteFunctionHandler';

import { termToPrimitive } from './valueUtils';
import { handler } from './handlerUtil';

@@ -36,2 +38,8 @@ /**

// Add utilities for collections
list: listHandler(),
container: containerHandler(false),
containerAsSet: containerHandler(true),
collection: collectionHandler(),
// Add read and query functionality

@@ -80,7 +88,2 @@ get: new GetHandler(),

// Creates a handler from the given function
function handler(handle) {
return { handle };
}
// Creates a handler for the given RDF/JS Term property

@@ -87,0 +90,0 @@ function termPropertyHandler(property) {