Comparing version 2.1.0 to 2.2.0
(function() { | ||
'use strict'; | ||
var CND, Datom, LFT, LFT_nofreeze, MAIN, Multimix, assign, badge, copy, debug, defaults, echo, help, info, isa, jr, p1, p2, rpr, type_of, types, urge, validate, warn, whisper, | ||
var CND, Datom, LFT, LFT_nofreeze, MAIN, Multimix, assign, badge, copy, debug, defaults, echo, help, info, isa, jr, p1, p2, rpr, type_of, urge, validate, warn, whisper, | ||
indexOf = [].indexOf; | ||
@@ -32,5 +32,5 @@ | ||
types = require('./types'); | ||
this.types = require('./types'); | ||
({isa, validate, defaults, type_of} = types); | ||
({isa, validate, defaults, type_of} = this.types); | ||
@@ -164,3 +164,2 @@ LFT = require('letsfreezethat'); | ||
var R; | ||
/* TAINT should validate key */ | ||
/* When `other` contains a key `$`, it is treated as a hint to copy | ||
@@ -172,3 +171,2 @@ system-level attributes; if the value of key `$` is a POD that has itself a | ||
validate.datom_key($key); | ||
validate.datom_value($value); | ||
if ($value != null) { | ||
@@ -178,5 +176,5 @@ if ((!this.settings.merge_values) || (!isa.object($value))) { | ||
} | ||
R = assign({$key}, $value, ...other); | ||
R = assign({}, $value, ...other, {$key}); | ||
} else { | ||
R = assign({$key}, ...other); | ||
R = assign({}, ...other, {$key}); | ||
} | ||
@@ -190,2 +188,15 @@ while ((isa.object(R.$)) && (isa.object(R.$.$))) { | ||
//----------------------------------------------------------------------------------------------------------- | ||
this.wrap_datom = function($key, $value) { | ||
var R; | ||
/* TAINT code duplication */ | ||
validate.datom_key($key); | ||
validate.datom_datom($value); | ||
R = assign({}, {$key, $value}); | ||
while ((isa.object(R.$)) && (isa.object(R.$.$))) { | ||
R.$ = copy(R.$.$); | ||
} | ||
return this.freeze(R); | ||
}; | ||
//----------------------------------------------------------------------------------------------------------- | ||
this.new_single_datom = function($key, $value, ...other) { | ||
@@ -192,0 +203,0 @@ return this.new_datom(`^${$key}`, $value, ...other); |
@@ -538,2 +538,38 @@ (function() { | ||
//----------------------------------------------------------------------------------------------------------- | ||
this["wrap_datom"] = async function(T, done) { | ||
var DATOM, error, i, len, matcher, new_datom, probe, probes_and_matchers, select, wrap_datom; | ||
DATOM = require('../..'); | ||
({new_datom, wrap_datom, select} = DATOM.export()); | ||
//......................................................................................................... | ||
probes_and_matchers = [ | ||
[ | ||
["^text", | ||
'helo'], | ||
{ | ||
"$key": "^wrapper", | ||
"$value": { | ||
"$key": "^text", | ||
"$value": "helo" | ||
} | ||
}, | ||
null | ||
] | ||
]; | ||
//......................................................................................................... | ||
for (i = 0, len = probes_and_matchers.length; i < len; i++) { | ||
[probe, matcher, error] = probes_and_matchers[i]; | ||
await T.perform(probe, matcher, error, function() { | ||
return new Promise(function(resolve, reject) { | ||
var d, key, value; | ||
[key, value] = probe; | ||
d = new_datom(key, value); | ||
return resolve(wrap_datom('^wrapper', d)); | ||
}); | ||
}); | ||
} | ||
done(); | ||
return null; | ||
}; | ||
//----------------------------------------------------------------------------------------------------------- | ||
this["new_datom (without value merging)"] = async function(T, done) { | ||
@@ -745,3 +781,4 @@ var DATOM, error, i, len, matcher, new_datom, probe, probes_and_matchers, select; | ||
(() => { | ||
return test(this); | ||
// test @ | ||
return test(this["wrap_datom"]); | ||
})(); | ||
@@ -748,0 +785,0 @@ } |
@@ -108,10 +108,2 @@ (function() { | ||
//----------------------------------------------------------------------------------------------------------- | ||
this.declare('datom_value', function(x) { | ||
if (!this.isa.object(x)) { | ||
return true; | ||
} | ||
return x.$key === void 0; | ||
}); | ||
//----------------------------------------------------------------------------------------------------------- | ||
this.defaults = { | ||
@@ -118,0 +110,0 @@ settings: { |
{ | ||
"name": "datom", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "standardized immutable objects in the spirit of datomic, especially suited for use in data pipelines", | ||
@@ -5,0 +5,0 @@ "main": "lib/main.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
94930
1346