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

@gram-data/gram-identity

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gram-data/gram-identity - npm Package Compare versions

Comparing version 0.1.2 to 0.2.5

dist/gram-identity/src/gram-identity-plugin.d.ts

104

dist/gram-identity.cjs.development.js

@@ -5,12 +5,22 @@ 'use strict';

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var gramAst = require('@gram-data/gram-ast');
var baseX = _interopDefault(require('base-x'));
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
/**
* Utility functions for Gram element identifiers.
*
* @packageDocumentation
*/
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
var shortid = /*#__PURE__*/require('shortid');

@@ -35,62 +45,46 @@

/**
* Identifier function which produces a pseudo-random, short identifier.
*
* @param n Converted to fixed-point number with no decimals.
*/
var decodeInteger = function decodeInteger(n) {
var base10 = baseX(alphabets.base10);
if (n > Number.MAX_SAFE_INTEGER) throw Error('Value cannot exceed Number.MAX_SAFE_INTEGER.');
return base10.decode(n.toFixed(0));
};
var integerToBase = function integerToBase(alphabet, n) {
return baseX(alphabet).encode(decodeInteger(n));
};
var integerToBaseID = function integerToBaseID(alphabet, n) {
return '_' + baseX(alphabet).encode(decodeInteger(n));
};
/**
* Convert an arbitrary length base-10 integer literal into valid identifier in another base representation.
*
* @param alphabet alphabet for base-x output
* @param n base-10 numeric string input
*/
var shortID = shortid.generate;
var integerLiteralToBaseID = function integerLiteralToBaseID(alphabet, n) {
return '_' + baseX(alphabet).encode(baseX(alphabets.base10).decode(n));
var visit = /*#__PURE__*/require('unist-util-visit');
var defaultSettings = {
kind: 'numeric'
};
/**
* Identifier function which produces a pseudo-random, short identifier.
*
*/
var shortID = shortid.generate;
/**
* Identifier function
*
* @param i
*/
var gramIdentityPlugin = function gramIdentityPlugin(s) {
if (s === void 0) {
s = defaultSettings;
}
var base36ID = function base36ID(i) {
return "_" + i.toString(36);
};
var idFunctionNamed = function idFunctionNamed(idType) {
return idType === 'number' ? function (i) {
return "" + i;
} : idType === 'shortid' ? function (_) {
return shortID();
} : idType === 'base36' ? base36ID : // : idType === 'base58'
// ? base58ID
function (_i) {
return '';
var mergedSettings = _extends({}, defaultSettings, s);
var identification = function identification(tree) {
var counter = 0;
visit(tree, function (element) {
if (gramAst.isGramPathlike(element)) {
switch (mergedSettings.kind) {
case 'numeric':
element.id = element.id || "" + counter++;
break;
case 'shortid':
element.id = element.id || shortID();
break;
}
}
});
};
return identification;
};
module.exports = gramIdentityPlugin;
exports.alphabets = alphabets;
exports.base36ID = base36ID;
exports.decodeInteger = decodeInteger;
exports.idFunctionNamed = idFunctionNamed;
exports.integerLiteralToBaseID = integerLiteralToBaseID;
exports.integerToBase = integerToBase;
exports.integerToBaseID = integerToBaseID;
exports.gramIdentityPlugin = gramIdentityPlugin;
exports.shortID = shortID;
//# sourceMappingURL=gram-identity.cjs.development.js.map

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=(e=require("base-x"))&&"object"==typeof e&&"default"in e?e.default:e,t=require("shortid"),n={base2:"01",base8:"01234567",base10:"0123456789",base11:"0123456789a",base16:"0123456789abcdef",base32:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",zBase32:"ybndrfg8ejkmcpqxot1uwisza345h769",crock32:"0123456789ABCDEFGHJKMNPQRSTVWXYZ",base32Hex:"0123456789ABCDEFGHIJKLMNOPQRSTUV",base36:"0123456789abcdefghijklmnopqrstuvwxyz",base58:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ",base62:"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",base64:"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@"};t.characters(n.base64);var o=function(e){var t=r(n.base10);if(e>Number.MAX_SAFE_INTEGER)throw Error("Value cannot exceed Number.MAX_SAFE_INTEGER.");return t.decode(e.toFixed(0))},a=t.generate,s=function(e){return"_"+e.toString(36)};exports.alphabets=n,exports.base36ID=s,exports.decodeInteger=o,exports.idFunctionNamed=function(e){return"number"===e?function(e){return""+e}:"shortid"===e?function(e){return a()}:"base36"===e?s:function(e){return""}},exports.integerLiteralToBaseID=function(e,t){return"_"+r(e).encode(r(n.base10).decode(t))},exports.integerToBase=function(e,t){return r(e).encode(o(t))},exports.integerToBaseID=function(e,t){return"_"+r(e).encode(o(t))},exports.shortID=a;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@gram-data/gram-ast");function r(){return(r=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var t in a)Object.prototype.hasOwnProperty.call(a,t)&&(e[t]=a[t])}return e}).apply(this,arguments)}var a=require("shortid"),t={base2:"01",base8:"01234567",base10:"0123456789",base11:"0123456789a",base16:"0123456789abcdef",base32:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",zBase32:"ybndrfg8ejkmcpqxot1uwisza345h769",crock32:"0123456789ABCDEFGHJKMNPQRSTVWXYZ",base32Hex:"0123456789ABCDEFGHIJKLMNOPQRSTUV",base36:"0123456789abcdefghijklmnopqrstuvwxyz",base58:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ",base62:"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",base64:"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@"};a.characters(t.base64);var s=a.generate,i=require("unist-util-visit"),n={kind:"numeric"},o=function(a){void 0===a&&(a=n);var t=r({},n,a);return function(r){var a=0;i(r,(function(r){if(e.isGramPathlike(r))switch(t.kind){case"numeric":r.id=r.id||""+a++;break;case"shortid":r.id=r.id||s()}}))}};module.exports=o,exports.alphabets=t,exports.gramIdentityPlugin=o,exports.shortID=s;
//# sourceMappingURL=gram-identity.cjs.production.min.js.map

@@ -1,9 +0,21 @@

import baseX from 'base-x';
import { isGramPathlike } from '@gram-data/gram-ast';
/**
* Utility functions for Gram element identifiers.
*
* @packageDocumentation
*/
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
var shortid = /*#__PURE__*/require('shortid');

@@ -28,55 +40,44 @@

/**
* Identifier function which produces a pseudo-random, short identifier.
*
* @param n Converted to fixed-point number with no decimals.
*/
var decodeInteger = function decodeInteger(n) {
var base10 = baseX(alphabets.base10);
if (n > Number.MAX_SAFE_INTEGER) throw Error('Value cannot exceed Number.MAX_SAFE_INTEGER.');
return base10.decode(n.toFixed(0));
};
var integerToBase = function integerToBase(alphabet, n) {
return baseX(alphabet).encode(decodeInteger(n));
};
var integerToBaseID = function integerToBaseID(alphabet, n) {
return '_' + baseX(alphabet).encode(decodeInteger(n));
};
/**
* Convert an arbitrary length base-10 integer literal into valid identifier in another base representation.
*
* @param alphabet alphabet for base-x output
* @param n base-10 numeric string input
*/
var shortID = shortid.generate;
var integerLiteralToBaseID = function integerLiteralToBaseID(alphabet, n) {
return '_' + baseX(alphabet).encode(baseX(alphabets.base10).decode(n));
var visit = /*#__PURE__*/require('unist-util-visit');
var defaultSettings = {
kind: 'numeric'
};
/**
* Identifier function which produces a pseudo-random, short identifier.
*
*/
var shortID = shortid.generate;
/**
* Identifier function
*
* @param i
*/
var gramIdentityPlugin = function gramIdentityPlugin(s) {
if (s === void 0) {
s = defaultSettings;
}
var base36ID = function base36ID(i) {
return "_" + i.toString(36);
};
var idFunctionNamed = function idFunctionNamed(idType) {
return idType === 'number' ? function (i) {
return "" + i;
} : idType === 'shortid' ? function (_) {
return shortID();
} : idType === 'base36' ? base36ID : // : idType === 'base58'
// ? base58ID
function (_i) {
return '';
var mergedSettings = _extends({}, defaultSettings, s);
var identification = function identification(tree) {
var counter = 0;
visit(tree, function (element) {
if (isGramPathlike(element)) {
switch (mergedSettings.kind) {
case 'numeric':
element.id = element.id || "" + counter++;
break;
case 'shortid':
element.id = element.id || shortID();
break;
}
}
});
};
return identification;
};
export { alphabets, base36ID, decodeInteger, idFunctionNamed, integerLiteralToBaseID, integerToBase, integerToBaseID, shortID };
module.exports = gramIdentityPlugin;
export { alphabets, gramIdentityPlugin, shortID };
//# sourceMappingURL=gram-identity.esm.js.map

@@ -1,2 +0,2 @@

!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(((t=t||self).gram=t.gram||{},t.gram.identity={}))}(this,(function(t){"use strict";var r=[],e=[],n="undefined"!=typeof Uint8Array?Uint8Array:Array,o=!1;function i(){o=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=0,i=t.length;n<i;++n)r[n]=t[n],e[t.charCodeAt(n)]=n;e["-".charCodeAt(0)]=62,e["_".charCodeAt(0)]=63}function f(t,e,n){for(var o,i=[],f=e;f<n;f+=3)i.push(r[(o=(t[f]<<16)+(t[f+1]<<8)+t[f+2])>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return i.join("")}function u(t,r,e,n,o){var i,f,u=8*o-n-1,a=(1<<u)-1,s=a>>1,h=-7,c=e?o-1:0,l=e?-1:1,p=t[r+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=u;h>0;i=256*i+t[r+c],c+=l,h-=8);for(f=i&(1<<-h)-1,i>>=-h,h+=n;h>0;f=256*f+t[r+c],c+=l,h-=8);if(0===i)i=1-s;else{if(i===a)return f?NaN:Infinity*(p?-1:1);f+=Math.pow(2,n),i-=s}return(p?-1:1)*f*Math.pow(2,i-n)}function a(t,r,e,n,o,i){var f,u,a,s=8*i-o-1,h=(1<<s)-1,c=h>>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,g=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||Infinity===r?(u=isNaN(r)?1:0,f=h):(f=Math.floor(Math.log(r)/Math.LN2),r*(a=Math.pow(2,-f))<1&&(f--,a*=2),(r+=f+c>=1?l/a:l*Math.pow(2,1-c))*a>=2&&(f++,a/=2),f+c>=h?(u=0,f=h):f+c>=1?(u=(r*a-1)*Math.pow(2,o),f+=c):(u=r*Math.pow(2,c-1)*Math.pow(2,o),f=0));o>=8;t[e+p]=255&u,p+=g,u/=256,o-=8);for(f=f<<o|u,s+=o;s>0;t[e+p]=255&f,p+=g,f/=256,s-=8);t[e+p-g]|=128*y}var s={}.toString,h=Array.isArray||function(t){return"[object Array]"==s.call(t)};g.TYPED_ARRAY_SUPPORT=void 0===global.TYPED_ARRAY_SUPPORT||global.TYPED_ARRAY_SUPPORT;var c=l();function l(){return g.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function p(t,r){if(l()<r)throw new RangeError("Invalid typed array length");return g.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(r)).__proto__=g.prototype:(null===t&&(t=new g(r)),t.length=r),t}function g(t,r,e){if(!(g.TYPED_ARRAY_SUPPORT||this instanceof g))return new g(t,r,e);if("number"==typeof t){if("string"==typeof r)throw new Error("If encoding is specified then the first argument must be a string");return d(this,t)}return y(this,t,r,e)}function y(t,r,e,n){if("number"==typeof r)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&r instanceof ArrayBuffer?function(t,r,e,n){if(e<0||r.byteLength<e)throw new RangeError("'offset' is out of bounds");if(r.byteLength<e+(n||0))throw new RangeError("'length' is out of bounds");return r=void 0===e&&void 0===n?new Uint8Array(r):void 0===n?new Uint8Array(r,e):new Uint8Array(r,e,n),g.TYPED_ARRAY_SUPPORT?(t=r).__proto__=g.prototype:t=v(t,r),t}(t,r,e,n):"string"==typeof r?function(t,r,e){if("string"==typeof e&&""!==e||(e="utf8"),!g.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var n=0|A(r,e),o=(t=p(t,n)).write(r,e);return o!==n&&(t=t.slice(0,o)),t}(t,r,e):function(t,r){if(b(r)){var e=0|E(r.length);return 0===(t=p(t,e)).length||r.copy(t,0,0,e),t}if(r){if("undefined"!=typeof ArrayBuffer&&r.buffer instanceof ArrayBuffer||"length"in r)return"number"!=typeof r.length||(n=r.length)!=n?p(t,0):v(t,r);if("Buffer"===r.type&&h(r.data))return v(t,r.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,r)}function w(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function d(t,r){if(w(r),t=p(t,r<0?0:0|E(r)),!g.TYPED_ARRAY_SUPPORT)for(var e=0;e<r;++e)t[e]=0;return t}function v(t,r){var e=r.length<0?0:0|E(r.length);t=p(t,e);for(var n=0;n<e;n+=1)t[n]=255&r[n];return t}function E(t){if(t>=l())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+l().toString(16)+" bytes");return 0|t}function b(t){return!(null==t||!t._isBuffer)}function A(t,r){if(b(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var e=t.length;if(0===e)return 0;for(var n=!1;;)switch(r){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return H(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*e;case"hex":return e>>>1;case"base64":return J(t).length;default:if(n)return H(t).length;r=(""+r).toLowerCase(),n=!0}}function m(t,r,e){var n=!1;if((void 0===r||r<0)&&(r=0),r>this.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return O(this,r,e);case"utf8":case"utf-8":return C(this,r,e);case"ascii":return x(this,r,e);case"latin1":case"binary":return D(this,r,e);case"base64":return M(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function R(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function _(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=o?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=g.from(r,n)),b(r))return 0===r.length?-1:T(t,r,e,n,o);if("number"==typeof r)return r&=255,g.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):T(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function T(t,r,e,n,o){var i,f=1,u=t.length,a=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;f=2,u/=2,a/=2,e/=2}function s(t,r){return 1===f?t[r]:t.readUInt16BE(r*f)}if(o){var h=-1;for(i=e;i<u;i++)if(s(t,i)===s(r,-1===h?0:i-h)){if(-1===h&&(h=i),i-h+1===a)return h*f}else-1!==h&&(i-=i-h),h=-1}else for(e+a>u&&(e=u-a),i=e;i>=0;i--){for(var c=!0,l=0;l<a;l++)if(s(t,i+l)!==s(r,l)){c=!1;break}if(c)return i}return-1}function P(t,r,e,n){e=Number(e)||0;var o=t.length-e;n?(n=Number(n))>o&&(n=o):n=o;var i=r.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var f=0;f<n;++f){var u=parseInt(r.substr(2*f,2),16);if(isNaN(u))return f;t[e+f]=u}return f}function U(t,r,e,n){return K(H(r,t.length-e),t,e,n)}function B(t,r,e,n){return K(function(t){for(var r=[],e=0;e<t.length;++e)r.push(255&t.charCodeAt(e));return r}(r),t,e,n)}function S(t,r,e,n){return B(t,r,e,n)}function I(t,r,e,n){return K(J(r),t,e,n)}function Y(t,r,e,n){return K(function(t,r){for(var e,n,o=[],i=0;i<t.length&&!((r-=2)<0);++i)n=(e=t.charCodeAt(i))>>8,o.push(e%256),o.push(n);return o}(r,t.length-e),t,e,n)}function M(t,e,n){return function(t){var e;o||i();for(var n=t.length,u=n%3,a="",s=[],h=0,c=n-u;h<c;h+=16383)s.push(f(t,h,h+16383>c?c:h+16383));return 1===u?(a+=r[(e=t[n-1])>>2],a+=r[e<<4&63],a+="=="):2===u&&(a+=r[(e=(t[n-2]<<8)+t[n-1])>>10],a+=r[e>>4&63],a+=r[e<<2&63],a+="="),s.push(a),s.join("")}(0===e&&n===t.length?t:t.slice(e,n))}function C(t,r,e){e=Math.min(t.length,e);for(var n=[],o=r;o<e;){var i,f,u,a,s=t[o],h=null,c=s>239?4:s>223?3:s>191?2:1;if(o+c<=e)switch(c){case 1:s<128&&(h=s);break;case 2:128==(192&(i=t[o+1]))&&(a=(31&s)<<6|63&i)>127&&(h=a);break;case 3:f=t[o+2],128==(192&(i=t[o+1]))&&128==(192&f)&&(a=(15&s)<<12|(63&i)<<6|63&f)>2047&&(a<55296||a>57343)&&(h=a);break;case 4:f=t[o+2],u=t[o+3],128==(192&(i=t[o+1]))&&128==(192&f)&&128==(192&u)&&(a=(15&s)<<18|(63&i)<<12|(63&f)<<6|63&u)>65535&&a<1114112&&(h=a)}null===h?(h=65533,c=1):h>65535&&(n.push((h-=65536)>>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=4096)return String.fromCharCode.apply(String,t);for(var e="",n=0;n<r;)e+=String.fromCharCode.apply(String,t.slice(n,n+=4096));return e}(n)}function x(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;o<e;++o)n+=String.fromCharCode(127&t[o]);return n}function D(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;o<e;++o)n+=String.fromCharCode(t[o]);return n}function O(t,r,e){var n=t.length;(!r||r<0)&&(r=0),(!e||e<0||e>n)&&(e=n);for(var o="",i=r;i<e;++i)o+=q(t[i]);return o}function L(t,r,e){for(var n=t.slice(r,e),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function N(t,r,e){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+r>e)throw new RangeError("Trying to access beyond buffer length")}function k(t,r,e,n,o,i){if(!b(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>o||r<i)throw new RangeError('"value" argument is out of bounds');if(e+n>t.length)throw new RangeError("Index out of range")}function F(t,r,e,n){r<0&&(r=65535+r+1);for(var o=0,i=Math.min(t.length-e,2);o<i;++o)t[e+o]=(r&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function z(t,r,e,n){r<0&&(r=4294967295+r+1);for(var o=0,i=Math.min(t.length-e,4);o<i;++o)t[e+o]=r>>>8*(n?o:3-o)&255}function j(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function V(t,r,e,n,o){return o||j(t,0,e,4),a(t,r,e,n,23,4),e+4}function G(t,r,e,n,o){return o||j(t,0,e,8),a(t,r,e,n,52,8),e+8}g.poolSize=8192,g._augment=function(t){return t.__proto__=g.prototype,t},g.from=function(t,r,e){return y(null,t,r,e)},g.TYPED_ARRAY_SUPPORT&&(g.prototype.__proto__=Uint8Array.prototype,g.__proto__=Uint8Array),g.alloc=function(t,r,e){return function(t,r,e,n){return w(r),r<=0?p(null,r):void 0!==e?"string"==typeof n?p(null,r).fill(e,n):p(null,r).fill(e):p(null,r)}(0,t,r,e)},g.allocUnsafe=function(t){return d(null,t)},g.allocUnsafeSlow=function(t){return d(null,t)},g.isBuffer=Q,g.compare=function(t,r){if(!b(t)||!b(r))throw new TypeError("Arguments must be Buffers");if(t===r)return 0;for(var e=t.length,n=r.length,o=0,i=Math.min(e,n);o<i;++o)if(t[o]!==r[o]){e=t[o],n=r[o];break}return e<n?-1:n<e?1:0},g.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},g.concat=function(t,r){if(!h(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return g.alloc(0);var e;if(void 0===r)for(r=0,e=0;e<t.length;++e)r+=t[e].length;var n=g.allocUnsafe(r),o=0;for(e=0;e<t.length;++e){var i=t[e];if(!b(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(n,o),o+=i.length}return n},g.byteLength=A,g.prototype._isBuffer=!0,g.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;r<t;r+=2)R(this,r,r+1);return this},g.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;r<t;r+=4)R(this,r,r+3),R(this,r+1,r+2);return this},g.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;r<t;r+=8)R(this,r,r+7),R(this,r+1,r+6),R(this,r+2,r+5),R(this,r+3,r+4);return this},g.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?C(this,0,t):m.apply(this,arguments)},g.prototype.equals=function(t){if(!b(t))throw new TypeError("Argument must be a Buffer");return this===t||0===g.compare(this,t)},g.prototype.inspect=function(){var t="";return this.length>0&&(t=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(t+=" ... ")),"<Buffer "+t+">"},g.prototype.compare=function(t,r,e,n,o){if(!b(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&r>=e)return 0;if(n>=o)return-1;if(r>=e)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),f=(e>>>=0)-(r>>>=0),u=Math.min(i,f),a=this.slice(n,o),s=t.slice(r,e),h=0;h<u;++h)if(a[h]!==s[h]){i=a[h],f=s[h];break}return i<f?-1:f<i?1:0},g.prototype.includes=function(t,r,e){return-1!==this.indexOf(t,r,e)},g.prototype.indexOf=function(t,r,e){return _(this,t,r,e,!0)},g.prototype.lastIndexOf=function(t,r,e){return _(this,t,r,e,!1)},g.prototype.write=function(t,r,e,n){if(void 0===r)n="utf8",e=this.length,r=0;else if(void 0===e&&"string"==typeof r)n=r,e=this.length,r=0;else{if(!isFinite(r))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");r|=0,isFinite(e)?(e|=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||e>o)&&(e=o),t.length>0&&(e<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return P(this,t,r,e);case"utf8":case"utf-8":return U(this,t,r,e);case"ascii":return B(this,t,r,e);case"latin1":case"binary":return S(this,t,r,e);case"base64":return I(this,t,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Y(this,t,r,e);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},g.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},g.prototype.slice=function(t,r){var e,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(r=void 0===r?n:~~r)<0?(r+=n)<0&&(r=0):r>n&&(r=n),r<t&&(r=t),g.TYPED_ARRAY_SUPPORT)(e=this.subarray(t,r)).__proto__=g.prototype;else{var o=r-t;e=new g(o,void 0);for(var i=0;i<o;++i)e[i]=this[i+t]}return e},g.prototype.readUIntLE=function(t,r,e){t|=0,r|=0,e||N(t,r,this.length);for(var n=this[t],o=1,i=0;++i<r&&(o*=256);)n+=this[t+i]*o;return n},g.prototype.readUIntBE=function(t,r,e){t|=0,r|=0,e||N(t,r,this.length);for(var n=this[t+--r],o=1;r>0&&(o*=256);)n+=this[t+--r]*o;return n},g.prototype.readUInt8=function(t,r){return r||N(t,1,this.length),this[t]},g.prototype.readUInt16LE=function(t,r){return r||N(t,2,this.length),this[t]|this[t+1]<<8},g.prototype.readUInt16BE=function(t,r){return r||N(t,2,this.length),this[t]<<8|this[t+1]},g.prototype.readUInt32LE=function(t,r){return r||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},g.prototype.readUInt32BE=function(t,r){return r||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},g.prototype.readIntLE=function(t,r,e){t|=0,r|=0,e||N(t,r,this.length);for(var n=this[t],o=1,i=0;++i<r&&(o*=256);)n+=this[t+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*r)),n},g.prototype.readIntBE=function(t,r,e){t|=0,r|=0,e||N(t,r,this.length);for(var n=r,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*r)),i},g.prototype.readInt8=function(t,r){return r||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},g.prototype.readInt16LE=function(t,r){r||N(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},g.prototype.readInt16BE=function(t,r){r||N(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},g.prototype.readInt32LE=function(t,r){return r||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},g.prototype.readInt32BE=function(t,r){return r||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},g.prototype.readFloatLE=function(t,r){return r||N(t,4,this.length),u(this,t,!0,23,4)},g.prototype.readFloatBE=function(t,r){return r||N(t,4,this.length),u(this,t,!1,23,4)},g.prototype.readDoubleLE=function(t,r){return r||N(t,8,this.length),u(this,t,!0,52,8)},g.prototype.readDoubleBE=function(t,r){return r||N(t,8,this.length),u(this,t,!1,52,8)},g.prototype.writeUIntLE=function(t,r,e,n){t=+t,r|=0,e|=0,n||k(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i<e&&(o*=256);)this[r+i]=t/o&255;return r+e},g.prototype.writeUIntBE=function(t,r,e,n){t=+t,r|=0,e|=0,n||k(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;--o>=0&&(i*=256);)this[r+o]=t/i&255;return r+e},g.prototype.writeUInt8=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,1,255,0),g.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=255&t,r+1},g.prototype.writeUInt16LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,65535,0),g.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):F(this,t,r,!0),r+2},g.prototype.writeUInt16BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,65535,0),g.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):F(this,t,r,!1),r+2},g.prototype.writeUInt32LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,4294967295,0),g.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t):z(this,t,r,!0),r+4},g.prototype.writeUInt32BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,4294967295,0),g.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):z(this,t,r,!1),r+4},g.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r|=0,!n){var o=Math.pow(2,8*e-1);k(this,t,r,e,o-1,-o)}var i=0,f=1,u=0;for(this[r]=255&t;++i<e&&(f*=256);)t<0&&0===u&&0!==this[r+i-1]&&(u=1),this[r+i]=(t/f>>0)-u&255;return r+e},g.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r|=0,!n){var o=Math.pow(2,8*e-1);k(this,t,r,e,o-1,-o)}var i=e-1,f=1,u=0;for(this[r+i]=255&t;--i>=0&&(f*=256);)t<0&&0===u&&0!==this[r+i+1]&&(u=1),this[r+i]=(t/f>>0)-u&255;return r+e},g.prototype.writeInt8=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,1,127,-128),g.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[r]=255&t,r+1},g.prototype.writeInt16LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,32767,-32768),g.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):F(this,t,r,!0),r+2},g.prototype.writeInt16BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,32767,-32768),g.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):F(this,t,r,!1),r+2},g.prototype.writeInt32LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,2147483647,-2147483648),g.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):z(this,t,r,!0),r+4},g.prototype.writeInt32BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),g.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):z(this,t,r,!1),r+4},g.prototype.writeFloatLE=function(t,r,e){return V(this,t,r,!0,e)},g.prototype.writeFloatBE=function(t,r,e){return V(this,t,r,!1,e)},g.prototype.writeDoubleLE=function(t,r,e){return G(this,t,r,!0,e)},g.prototype.writeDoubleBE=function(t,r,e){return G(this,t,r,!1,e)},g.prototype.copy=function(t,r,e,n){if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),n>0&&n<e&&(n=e),n===e)return 0;if(0===t.length||0===this.length)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(e<0||e>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r<n-e&&(n=t.length-r+e);var o,i=n-e;if(this===t&&e<r&&r<n)for(o=i-1;o>=0;--o)t[o+r]=this[o+e];else if(i<1e3||!g.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)t[o+r]=this[o+e];else Uint8Array.prototype.set.call(t,this.subarray(e,e+i),r);return i},g.prototype.fill=function(t,r,e,n){if("string"==typeof t){if("string"==typeof r?(n=r,r=0,e=this.length):"string"==typeof e&&(n=e,e=this.length),1===t.length){var o=t.charCodeAt(0);o<256&&(t=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!g.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(r<0||this.length<r||this.length<e)throw new RangeError("Out of range index");if(e<=r)return this;var i;if(r>>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i<e;++i)this[i]=t;else{var f=b(t)?t:H(new g(t,n).toString()),u=f.length;for(i=0;i<e-r;++i)this[i+r]=f[i%u]}return this};var X=/[^+\/0-9A-Za-z-_]/g;function q(t){return t<16?"0"+t.toString(16):t.toString(16)}function H(t,r){var e;r=r||Infinity;for(var n=t.length,o=null,i=[],f=0;f<n;++f){if((e=t.charCodeAt(f))>55295&&e<57344){if(!o){if(e>56319){(r-=3)>-1&&i.push(239,191,189);continue}if(f+1===n){(r-=3)>-1&&i.push(239,191,189);continue}o=e;continue}if(e<56320){(r-=3)>-1&&i.push(239,191,189),o=e;continue}e=65536+(o-55296<<10|e-56320)}else o&&(r-=3)>-1&&i.push(239,191,189);if(o=null,e<128){if((r-=1)<0)break;i.push(e)}else if(e<2048){if((r-=2)<0)break;i.push(e>>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function J(t){return function(t){var r,f,u,a,s,h;o||i();var c=t.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");h=new n(3*c/4-(s="="===t[c-2]?2:"="===t[c-1]?1:0)),u=s>0?c-4:c;var l=0;for(r=0,f=0;r<u;r+=4,f+=3)a=e[t.charCodeAt(r)]<<18|e[t.charCodeAt(r+1)]<<12|e[t.charCodeAt(r+2)]<<6|e[t.charCodeAt(r+3)],h[l++]=a>>16&255,h[l++]=a>>8&255,h[l++]=255&a;return 2===s?(a=e[t.charCodeAt(r)]<<2|e[t.charCodeAt(r+1)]>>4,h[l++]=255&a):1===s&&(a=e[t.charCodeAt(r)]<<10|e[t.charCodeAt(r+1)]<<4|e[t.charCodeAt(r+2)]>>2,h[l++]=a>>8&255,h[l++]=255&a),h}(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(X,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function K(t,r,e,n){for(var o=0;o<n&&!(o+e>=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function Q(t){return null!=t&&(!!t._isBuffer||Z(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&Z(t.slice(0,0))}(t))}function Z(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}var W,$=(W={__proto__:null,INSPECT_MAX_BYTES:50,kMaxLength:c,Buffer:g,SlowBuffer:function(t){return+t!=t&&(t=0),g.alloc(+t)},isBuffer:Q})&&W.default||W,tt=function(t,r){return function(t,r){var e=$.Buffer;function n(t,r){for(var e in t)r[e]=t[e]}function o(t,r,n){return e(t,r,n)}e.from&&e.alloc&&e.allocUnsafe&&e.allocUnsafeSlow?t.exports=$:(n($,r),r.Buffer=o),o.prototype=Object.create(e.prototype),n(e,o),o.from=function(t,r,n){if("number"==typeof t)throw new TypeError("Argument must not be a number");return e(t,r,n)},o.alloc=function(t,r,n){if("number"!=typeof t)throw new TypeError("Argument must be a number");var o=e(t);return void 0!==r?"string"==typeof n?o.fill(r,n):o.fill(r):o.fill(0),o},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return e(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return $.SlowBuffer(t)}}(r={exports:{}},r.exports),r.exports}().Buffer,rt=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),e=0;e<r.length;e++)r[e]=255;for(var n=0;n<t.length;n++){var o=t.charAt(n),i=o.charCodeAt(0);if(255!==r[i])throw new TypeError(o+" is ambiguous");r[i]=n}var f=t.length,u=t.charAt(0),a=Math.log(f)/Math.log(256),s=Math.log(256)/Math.log(f);function h(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return tt.alloc(0);var e=0;if(" "!==t[e]){for(var n=0,o=0;t[e]===u;)n++,e++;for(var i=(t.length-e)*a+1>>>0,s=new Uint8Array(i);t[e];){var h=r[t.charCodeAt(e)];if(255===h)return;for(var c=0,l=i-1;(0!==h||c<o)&&-1!==l;l--,c++)s[l]=(h+=f*s[l]>>>0)%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");o=c,e++}if(" "!==t[e]){for(var p=i-o;p!==i&&0===s[p];)p++;var g=tt.allocUnsafe(n+(i-p));g.fill(0,0,n);for(var y=n;p!==i;)g[y++]=s[p++];return g}}}return{encode:function(r){if((Array.isArray(r)||r instanceof Uint8Array)&&(r=tt.from(r)),!tt.isBuffer(r))throw new TypeError("Expected Buffer");if(0===r.length)return"";for(var e=0,n=0,o=0,i=r.length;o!==i&&0===r[o];)o++,e++;for(var a=(i-o)*s+1>>>0,h=new Uint8Array(a);o!==i;){for(var c=r[o],l=0,p=a-1;(0!==c||l<n)&&-1!==p;p--,l++)h[p]=(c+=256*h[p]>>>0)%f>>>0,c=c/f>>>0;if(0!==c)throw new Error("Non-zero carry");n=l,o++}for(var g=a-n;g!==a&&0===h[g];)g++;for(var y=u.repeat(e);g<a;++g)y+=t.charAt(h[g]);return y},decodeUnsafe:h,decode:function(t){var r=h(t);if(r)return r;throw new Error("Non-base"+f+" character")}}},et=require("shortid"),nt={base2:"01",base8:"01234567",base10:"0123456789",base11:"0123456789a",base16:"0123456789abcdef",base32:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",zBase32:"ybndrfg8ejkmcpqxot1uwisza345h769",crock32:"0123456789ABCDEFGHJKMNPQRSTVWXYZ",base32Hex:"0123456789ABCDEFGHIJKLMNOPQRSTUV",base36:"0123456789abcdefghijklmnopqrstuvwxyz",base58:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ",base62:"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",base64:"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@"};et.characters(nt.base64);var ot=function(t){var r=rt(nt.base10);if(t>Number.MAX_SAFE_INTEGER)throw Error("Value cannot exceed Number.MAX_SAFE_INTEGER.");return r.decode(t.toFixed(0))},it=et.generate,ft=function(t){return"_"+t.toString(36)};t.alphabets=nt,t.base36ID=ft,t.decodeInteger=ot,t.idFunctionNamed=function(t){return"number"===t?function(t){return""+t}:"shortid"===t?function(t){return it()}:"base36"===t?ft:function(t){return""}},t.integerLiteralToBaseID=function(t,r){return"_"+rt(t).encode(rt(nt.base10).decode(r))},t.integerToBase=function(t,r){return rt(t).encode(ot(r))},t.integerToBaseID=function(t,r){return"_"+rt(t).encode(ot(r))},t.shortID=it,Object.defineProperty(t,"__esModule",{value:!0})}));
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(((e=e||self).gram=e.gram||{},e.gram.identity={}))}(this,(function(e){"use strict";function r(){return(r=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}var t=function(e){return!!e.type&&"path"===e.type},n=function(e){return t(e)&&e.children&&0===e.children.length&&"ø"!==e.id},i=require("shortid"),a={base2:"01",base8:"01234567",base10:"0123456789",base11:"0123456789a",base16:"0123456789abcdef",base32:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",zBase32:"ybndrfg8ejkmcpqxot1uwisza345h769",crock32:"0123456789ABCDEFGHJKMNPQRSTVWXYZ",base32Hex:"0123456789ABCDEFGHIJKLMNOPQRSTUV",base36:"0123456789abcdefghijklmnopqrstuvwxyz",base58:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ",base62:"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",base64:"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@"};i.characters(a.base64);var o=i.generate,s=require("unist-util-visit"),u={kind:"numeric"},c=function(e){void 0===e&&(e=u);var i=r({},u,e);return function(e){var r=0;s(e,(function(e){if(t(a=e)||function(e){return t(e)&&void 0===e.children&&"ø"===e.id}(a)||n(a)||function(e){return t(e)&&void 0!==e.relation&&"pair"!==e.relation&&void 0!==e.children&&e.children.every((function(e){return n(e)}))}(a)||function(e){return!!e.type&&"seq"===e.type}(a))switch(i.kind){case"numeric":e.id=e.id||""+r++;break;case"shortid":e.id=e.id||o()}var a}))}};module.exports=c,e.alphabets=a,e.gramIdentityPlugin=c,e.shortID=o,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=gram-identity.umd.production.min.js.map
{
"name": "@gram-data/gram-identity",
"version": "0.1.2",
"keywords": [
"graph",
"neo4j",
"gram"
],
"version": "0.2.5",
"license": "MIT",

@@ -21,5 +26,5 @@ "main": "dist/index.js",

"lint:fix": "tsdx lint --fix",
"prepare": "run-s build",
"build:demo": "shx cp dist/gram-identity.umd.development.* ./public",
"demo": "serve ./public/"
"demo": "serve ./public/",
"prepare": "npm run build"
},

@@ -40,9 +45,9 @@ "husky": {

"devDependencies": {
"@gram-data/gram-parse": "^2.0.2",
"@types/jest": "^26.0.4",
"@types/shortid": "^0.0.29",
"@types/unist": "^2.0.3",
"@typescript-eslint/parser": "^3.5.0",
"@typescript-eslint/parser": "^3.6.1",
"husky": "^4.2.5",
"npm-run-all": "^4.1.5",
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-resolve": "^5.2.0",
"serve": "^11.3.2",

@@ -52,7 +57,11 @@ "shx": "^0.3.2",

"tslib": "^2.0.0",
"typescript": "^3.9.6"
"typescript": "^3.9.7",
"unist-util-inspect": "^6.0.0"
},
"dependencies": {
"base-x": "^3.0.8",
"shortid": "^2.2.15"
"@gram-data/gram-ast": "^0.2.5",
"shortid": "^2.2.15",
"unified": "^9.0.0",
"unist-util-visit": "^2.0.3",
"vfile": "^4.1.1"
},

@@ -62,3 +71,3 @@ "publishConfig": {

},
"gitHead": "0df0d0a9641c40097de62219503f626d3913de9c"
"gitHead": "6be75adbdf729a932bc55dbe7c4e8c3de9cb3da9"
}
# Gram Identity
Utilities for establishing or transforming graph element identity.
---
# TSDX Bootstrap
This project was bootstrapped with [TSDX](https://github.com/jaredpalmer/tsdx).
## Local Development
Below is a list of commands you will probably find useful.
### `npm start` or `yarn start`
Runs the project in development/watch mode. Your project will be rebuilt upon changes. TSDX has a special logger for you convenience. Error messages are pretty printed and formatted for compatibility VS Code's Problems tab.
<img src="https://user-images.githubusercontent.com/4060187/52168303-574d3a00-26f6-11e9-9f3b-71dbec9ebfcb.gif" width="600" />
Your library will be rebuilt if you make edits.
### `npm run build` or `yarn build`
Bundles the package to the `dist` folder.
The package is optimized and bundled with Rollup into multiple formats (CommonJS, UMD, and ES Module).
<img src="https://user-images.githubusercontent.com/4060187/52168322-a98e5b00-26f6-11e9-8cf6-222d716b75ef.gif" width="600" />
### `npm test` or `yarn test`
Runs the test watcher (Jest) in an interactive mode.
By default, runs tests related to files changed since the last commit.
Utilities for establishing or transforming the identity
of elements in a Gram AST.

@@ -1,9 +0,1 @@

/**
* Utility functions for Gram element identifiers.
*
* @packageDocumentation
*/
import baseX from 'base-x';
const shortid = require('shortid');

@@ -30,31 +22,2 @@

/**
*
* @param n Converted to fixed-point number with no decimals.
*/
export const decodeInteger = (n: number) => {
const base10 = baseX(alphabets.base10);
if (n > Number.MAX_SAFE_INTEGER)
throw Error('Value cannot exceed Number.MAX_SAFE_INTEGER.');
return base10.decode(n.toFixed(0));
};
export const integerToBase = (alphabet: string, n: number) => {
return baseX(alphabet).encode(decodeInteger(n));
};
export const integerToBaseID = (alphabet: string, n: number) => {
return '_' + baseX(alphabet).encode(decodeInteger(n));
};
/**
* Convert an arbitrary length base-10 integer literal into valid identifier in another base representation.
*
* @param alphabet alphabet for base-x output
* @param n base-10 numeric string input
*/
export const integerLiteralToBaseID = (alphabet: string, n: string) => {
return '_' + baseX(alphabet).encode(baseX(alphabets.base10).decode(n));
};
/**
* Identifier function which produces a pseudo-random, short identifier.

@@ -64,28 +27,1 @@ *

export const shortID = shortid.generate;
/**
* Identifier function
*
* @param i
*/
export const base36ID = (i: number) => `_${i.toString(36)}`;
export const idFunctionNamed = (idType: string) => {
return idType === 'number'
? (i: number) => `${i}`
: idType === 'shortid'
? (_: number) => shortID()
: idType === 'base36'
? base36ID
: // : idType === 'base58'
// ? base58ID
(_i: number) => '';
};
export default {
alphabets,
shortID,
base36ID,
idFunctionNamed,
integerLiteralToBaseID,
};

@@ -0,1 +1,7 @@

import gramIdentityPlugin from './gram-identity-plugin';
export * from './gram-identity';
export { gramIdentityPlugin };
module.exports = gramIdentityPlugin;

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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