Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

modelld

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

modelld - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

50

lib/model.js

@@ -34,3 +34,3 @@ 'use strict';

* NamedNode.
* @property {Immutable.Map<String, Field[]>} fields - The fields of this model
* @property {Immutable.Map<String, Field[]>} _fields - The fields of this model
* keyed by the field keys, which are user-specified aliases for RDF predicates.

@@ -85,3 +85,3 @@ * @property {Array[Object]} graveyard - An array of RDF quads which have been

this.subject = subject;
this.fields = fields;
this._fields = fields;
this.graveyard = graveyard;

@@ -100,8 +100,40 @@ Object.freeze(this);

_createClass(Model, [{
key: 'fields',
value: function fields(key) {
return this._fields.get(key) || [];
}
/**
* Get all the field values for a given key.
*
* @param {String} key - the key of the fields to look up.
* @returns {String[]} An array of field values for the given key.
*/
}, {
key: 'get',
value: function get(key) {
return this.fields.get(key) || [];
return this.fields(key).map(function (field) {
return field.value;
});
}
/**
* Get one of the field values for a given key. This just looks for the first
* field value, but order isn't guaranteed.
*
* @param {String} key - the key of the field to look up.
* @returns {String|undefined} The field value for the given key, or undefined
* if none was found.
*/
}, {
key: 'any',
value: function any(key) {
return this.fields(key).map(function (field) {
return field.value;
})[0];
}
/**
* Creates a model with an extra field.

@@ -117,3 +149,3 @@ *

value: function add(key, field) {
return new Model(this.subject, this.fields.set(key, [].concat(_toConsumableArray(this.fields.get(key)), [field])));
return new Model(this.subject, this._fields.set(key, [].concat(_toConsumableArray(this._fields.get(key)), [field])));
}

@@ -184,3 +216,3 @@

var diffMap = this.fields.toArray().reduce(function (reduction, cur) {
var diffMap = this._fields.toArray().reduce(function (reduction, cur) {
return [].concat(_toConsumableArray(reduction), _toConsumableArray(cur));

@@ -274,3 +306,3 @@ }).reduce(function (previousMap, field) {

value: function map(fn) {
return new Model(this.subject, this.fields.map(function (fieldsArray) {
return new Model(this.subject, this._fields.map(function (fieldsArray) {
return fieldsArray.map(fn);

@@ -292,3 +324,3 @@ }), this.graveyard);

value: function find(fn) {
return this.fields.reduce(function (fields, curFieldsArray) {
return this._fields.reduce(function (fields, curFieldsArray) {
return [].concat(_toConsumableArray(fields), _toConsumableArray(curFieldsArray));

@@ -314,3 +346,3 @@ }).find(function (field) {

var removedFields = [];
var newFields = this.fields.map(function (fieldsArray) {
var newFields = this._fields.map(function (fieldsArray) {
return fieldsArray.filter(function (field) {

@@ -336,3 +368,3 @@ var testPassed = fn(field);

value: function clearGraveyard() {
return new Model(this.subject, this.fields, []);
return new Model(this.subject, this._fields, []);
}

@@ -339,0 +371,0 @@ }]);

2

package.json
{
"name": "modelld",
"version": "0.4.0",
"version": "0.5.0",
"description": "A JavaScript API for selecting and manipulating linked data subgraphs",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

Sorry, the diff of this file is too big to display

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