data-joint
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -1,6 +0,6 @@ | ||
// Version 1.0.0 data-joint - https://github.com/vasturiano/data-joint | ||
// Version 1.1.0 data-joint - https://github.com/vasturiano/data-joint | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
(global = global || self, global.digest = factory()); | ||
(global = global || self, global.dataJoint = factory()); | ||
}(this, function () { 'use strict'; | ||
@@ -7,0 +7,0 @@ |
@@ -1,2 +0,2 @@ | ||
// Version 1.0.0 data-joint - https://github.com/vasturiano/data-joint | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t=t||self).digest=n()}(this,function(){"use strict";function t(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){var r=[],e=!0,o=!1,i=void 0;try{for(var a,u=t[Symbol.iterator]();!(e=(a=u.next()).done)&&(r.push(a.value),!n||r.length!==n);e=!0);}catch(t){o=!0,i=t}finally{try{e||null==u.return||u.return()}finally{if(o)throw i}}return r}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function n(t){return function(t){if(Array.isArray(t)){for(var n=0,r=new Array(t.length);n<t.length;n++)r[n]=t[n];return r}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var r,e=function(t,n){return t(n={exports:{}},n.exports),n.exports}(function(t,n){"undefined"!=typeof self&&self,t.exports=function(t){var n={};function r(e){if(n[e])return n[e].exports;var o=n[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=n,r.d=function(t,n,e){r.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:e})},r.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(n,"a",n),n},r.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},r.p="",r(r.s=0)}([function(t,n,r){var e,o,i;o=[t,n],void 0===(i="function"==typeof(e=function(t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(t,n){var r=!(2<arguments.length&&void 0!==arguments[2])||arguments[2],e=3<arguments.length&&void 0!==arguments[3]&&arguments[3],o=(n instanceof Array?n:[n]).map(function(t){return{keyAccessor:t,isProp:!(t instanceof Function)}}),i=t.reduce(function(t,n){var e=t,i=n;return o.forEach(function(t,n){var a=t.keyAccessor,u=void 0;if(t.isProp){var f=i,c=f[a],l=function(t,n){var r={};for(var e in t)0<=n.indexOf(e)||Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=t[e]);return r}(f,[a]);u=c,i=l}else u=a(i,n);n+1<o.length?(e.hasOwnProperty(u)||(e[u]={}),e=e[u]):r?(e.hasOwnProperty(u)||(e[u]=[]),e[u].push(i)):e[u]=i}),t},{});r instanceof Function&&function t(n){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;e===o.length?Object.keys(n).forEach(function(t){return n[t]=r(n[t])}):Object.values(n).forEach(function(n){return t(n,e+1)})}(i);var a=i;return e&&(a=[],function t(n){var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[];r.length===o.length?a.push({keys:r,vals:n}):Object.entries(n).forEach(function(n){var e=function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,n){var r=[],e=!0,o=!1,i=void 0;try{for(var a,u=t[Symbol.iterator]();!(e=(a=u.next()).done)&&(r.push(a.value),!n||r.length!==n);e=!0);}catch(t){o=!0,i=t}finally{try{!e&&u.return&&u.return()}finally{if(o)throw i}}return r}(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}(n,2),o=e[0],i=e[1];return t(i,[].concat(function(t){if(Array.isArray(t)){for(var n=0,r=Array(t.length);n<t.length;n++)r[n]=t[n];return r}return Array.from(t)}(r),[o]))})}(i)),a},t.exports=n.default})?e.apply(n,o):e)||(t.exports=i)}])}),o=(r=e)&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r;e.indexBy;function i(r,e,i){var a=i.objBindAttr,u=void 0===a?"__obj":a,f=i.dataBindAttr,c=void 0===f?"__data":f,l=i.idAccessor,d=function(t){return t.hasOwnProperty(c)},s=e.filter(function(t){return!d(t)}),p=function(r,e,i){var a={enter:[],update:[],exit:[]};if(i){var u=o(r,i,!1),f=o(e,i,!1),c=Object.assign({},u,f);Object.entries(c).forEach(function(n){var r=t(n,2),e=r[0],o=r[1],i=u.hasOwnProperty(e)?f.hasOwnProperty(e)?"update":"exit":"enter";a[i].push("update"===i?[u[e],f[e]]:o)})}else{var l=new Set(r),d=new Set(e);new Set([].concat(n(l),n(d))).forEach(function(t){var n=l.has(t)?d.has(t)?"update":"exit":"enter";a[n].push("update"===n?[t,t]:t)})}return a}(e.filter(d).map(function(t){return t[c]}),r,l);return p.update=p.update.map(function(n){var r=t(n,2),e=r[0],o=r[1];return e!==o&&(o[u]=e[u],o[u][c]=o),o}),p.exit=p.exit.concat(s.map(function(t){return function(t,n,r){return n in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,t}({},u,t)})),p}return function(t,r,e,o,a){var u=a.createObj,f=void 0===u?function(t){return{}}:u,c=a.updateObj,l=void 0===c?function(t,n){}:c,d=a.exitObj,s=void 0===d?function(t){}:d,p=a.objBindAttr,y=void 0===p?"__obj":p,v=a.dataBindAttr,h=void 0===v?"__data":v,b=a.idAccessor,O=i(t,r,{objBindAttr:y,dataBindAttr:h,idAccessor:b}),g=O.enter,w=O.update,A=O.exit,j=function(t){var n=[];return t.forEach(function(t){var r=f(t);r&&(r[h]=t,t[y]=r,n.push(r))}),n}(g);!function(t){t.forEach(function(t){var n=t[y];n&&(n[h]=t,l(n,t))})}([].concat(n(g),n(w))),j.forEach(e),A.forEach(function(t){var n=t[y];s(n),o(n)})}}); | ||
// Version 1.1.0 data-joint - https://github.com/vasturiano/data-joint | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t=t||self).dataJoint=n()}(this,function(){"use strict";function t(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){var r=[],e=!0,o=!1,i=void 0;try{for(var a,u=t[Symbol.iterator]();!(e=(a=u.next()).done)&&(r.push(a.value),!n||r.length!==n);e=!0);}catch(t){o=!0,i=t}finally{try{e||null==u.return||u.return()}finally{if(o)throw i}}return r}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function n(t){return function(t){if(Array.isArray(t)){for(var n=0,r=new Array(t.length);n<t.length;n++)r[n]=t[n];return r}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var r,e=function(t,n){return t(n={exports:{}},n.exports),n.exports}(function(t,n){"undefined"!=typeof self&&self,t.exports=function(t){var n={};function r(e){if(n[e])return n[e].exports;var o=n[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=n,r.d=function(t,n,e){r.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:e})},r.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(n,"a",n),n},r.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},r.p="",r(r.s=0)}([function(t,n,r){var e,o,i;o=[t,n],void 0===(i="function"==typeof(e=function(t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(t,n){var r=!(2<arguments.length&&void 0!==arguments[2])||arguments[2],e=3<arguments.length&&void 0!==arguments[3]&&arguments[3],o=(n instanceof Array?n:[n]).map(function(t){return{keyAccessor:t,isProp:!(t instanceof Function)}}),i=t.reduce(function(t,n){var e=t,i=n;return o.forEach(function(t,n){var a=t.keyAccessor,u=void 0;if(t.isProp){var f=i,c=f[a],l=function(t,n){var r={};for(var e in t)0<=n.indexOf(e)||Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=t[e]);return r}(f,[a]);u=c,i=l}else u=a(i,n);n+1<o.length?(e.hasOwnProperty(u)||(e[u]={}),e=e[u]):r?(e.hasOwnProperty(u)||(e[u]=[]),e[u].push(i)):e[u]=i}),t},{});r instanceof Function&&function t(n){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;e===o.length?Object.keys(n).forEach(function(t){return n[t]=r(n[t])}):Object.values(n).forEach(function(n){return t(n,e+1)})}(i);var a=i;return e&&(a=[],function t(n){var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[];r.length===o.length?a.push({keys:r,vals:n}):Object.entries(n).forEach(function(n){var e=function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,n){var r=[],e=!0,o=!1,i=void 0;try{for(var a,u=t[Symbol.iterator]();!(e=(a=u.next()).done)&&(r.push(a.value),!n||r.length!==n);e=!0);}catch(t){o=!0,i=t}finally{try{!e&&u.return&&u.return()}finally{if(o)throw i}}return r}(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}(n,2),o=e[0],i=e[1];return t(i,[].concat(function(t){if(Array.isArray(t)){for(var n=0,r=Array(t.length);n<t.length;n++)r[n]=t[n];return r}return Array.from(t)}(r),[o]))})}(i)),a},t.exports=n.default})?e.apply(n,o):e)||(t.exports=i)}])}),o=(r=e)&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r;e.indexBy;function i(r,e,i){var a=i.objBindAttr,u=void 0===a?"__obj":a,f=i.dataBindAttr,c=void 0===f?"__data":f,l=i.idAccessor,d=function(t){return t.hasOwnProperty(c)},s=e.filter(function(t){return!d(t)}),p=function(r,e,i){var a={enter:[],update:[],exit:[]};if(i){var u=o(r,i,!1),f=o(e,i,!1),c=Object.assign({},u,f);Object.entries(c).forEach(function(n){var r=t(n,2),e=r[0],o=r[1],i=u.hasOwnProperty(e)?f.hasOwnProperty(e)?"update":"exit":"enter";a[i].push("update"===i?[u[e],f[e]]:o)})}else{var l=new Set(r),d=new Set(e);new Set([].concat(n(l),n(d))).forEach(function(t){var n=l.has(t)?d.has(t)?"update":"exit":"enter";a[n].push("update"===n?[t,t]:t)})}return a}(e.filter(d).map(function(t){return t[c]}),r,l);return p.update=p.update.map(function(n){var r=t(n,2),e=r[0],o=r[1];return e!==o&&(o[u]=e[u],o[u][c]=o),o}),p.exit=p.exit.concat(s.map(function(t){return function(t,n,r){return n in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,t}({},u,t)})),p}return function(t,r,e,o,a){var u=a.createObj,f=void 0===u?function(t){return{}}:u,c=a.updateObj,l=void 0===c?function(t,n){}:c,d=a.exitObj,s=void 0===d?function(t){}:d,p=a.objBindAttr,y=void 0===p?"__obj":p,v=a.dataBindAttr,h=void 0===v?"__data":v,b=a.idAccessor,O=i(t,r,{objBindAttr:y,dataBindAttr:h,idAccessor:b}),w=O.enter,A=O.update,g=O.exit,j=function(t){var n=[];return t.forEach(function(t){var r=f(t);r&&(r[h]=t,t[y]=r,n.push(r))}),n}(w);!function(t){t.forEach(function(t){var n=t[y];n&&(n[h]=t,l(n,t))})}([].concat(n(w),n(A))),j.forEach(e),g.forEach(function(t){var n=t[y];s(n),o(n)})}}); |
{ | ||
"name": "data-joint", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Perform data joins with any type of JS objects", | ||
@@ -5,0 +5,0 @@ "unpkg": "dist/data-joint.min.js", |
# data-joint | ||
Perform data joins with any type of JavaScript objects. | ||
Library to perform data joins with any type of JavaScript objects. | ||
Useful in digest cycles where it's important to minimize changes to a view for performance reasons, such as DOM manipulation. | ||
The module binds data points to objects via hidden attributes, and performs diffing comparisons across multiple iterations to ensure objects are not created or removed unnecessarily, thus keeping view changes to a minimum. | ||
[![NPM](https://nodei.co/npm/data-joint.png?compact=true)](https://nodei.co/npm/data-joint/) | ||
@@ -9,7 +12,7 @@ | ||
``` | ||
import digest from 'data-joint'; | ||
import dataJoint from 'data-joint'; | ||
``` | ||
or | ||
``` | ||
const digest = require('data-joint'); | ||
const dataJoint = require('data-joint'); | ||
``` | ||
@@ -25,9 +28,9 @@ or even | ||
digest(myData, [...myView], | ||
dataJoint(myData, [...myView], | ||
obj => myView.add(obj), // append obj | ||
obj => myView.remove(obj), // remove obj | ||
obj => myView.delete(obj), // remove obj | ||
{ | ||
createObj: () => ({}), | ||
updateObj: (obj, d) => { d.double = d.val * 2 }, | ||
exitObj: obj => { d.double = 0 }, | ||
updateObj: (obj, d) => { obj.double = d.val * 2 }, | ||
exitObj: obj => { obj.double = 0 }, | ||
idAccessor: d => d.id | ||
@@ -42,3 +45,3 @@ } | ||
<b>digest</b>(<i>data</i>, <i>existingObjs</i>, <i>appendObjFn</i>, <i>removeObjFn</i>, [{<i>options</i>}]); | ||
<b>dataJoint</b>(<i>data</i>, <i>existingObjs</i>, <i>appendObjFn</i>, <i>removeObjFn</i>, [{<i>options</i>}]); | ||
@@ -66,4 +69,4 @@ ### Arguments | ||
| <b>dataBindAttr</b> | The attribute name used to bind view objects to data points. Each object maintained by the digest will be added this attribute, and it will be used for diffing across multiple iterations. | `__data` | | ||
| <b>idAccessor</b> | A data point accessor function to extract the point unique identifier. This used for comparing data points across multiple iterations. If no `idAccessor` is supplied the, data point object reference will be used instead for comparisons. The data point is passed as single argument: `d => {...}`. The method should return a unique identifier. | `undefined` | | ||
| <b>idAccessor</b> | A data point accessor function to extract the point unique identifier. This is used for comparing data points across multiple iterations. If no `idAccessor` is supplied, the data point object reference will be used instead for comparisons. The data point is passed as single argument: `d => {...}`. The method should return a unique identifier. | `undefined` | | ||
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
52544
10
69
0