@gram-data/gram-identity
Advanced tools
Comparing version 0.2.9 to 0.2.10
@@ -66,3 +66,3 @@ 'use strict'; | ||
visit(tree, function (element) { | ||
if (gramAst.isGramPathlike(element)) { | ||
if (gramAst.isGramPath(element)) { | ||
switch (mergedSettings.kind) { | ||
@@ -69,0 +69,0 @@ case 'numeric': |
@@ -1,2 +0,2 @@ | ||
"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"};exports.alphabets=t,exports.gramIdentityPlugin=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()}}))}},exports.shortID=s; | ||
"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"};exports.alphabets=t,exports.gramIdentityPlugin=function(a){void 0===a&&(a=n);var t=r({},n,a);return function(r){var a=0;i(r,(function(r){if(e.isGramPath(r))switch(t.kind){case"numeric":r.id=r.id||""+a++;break;case"shortid":r.id=r.id||s()}}))}},exports.shortID=s; | ||
//# sourceMappingURL=gram-identity.cjs.production.min.js.map |
@@ -1,2 +0,2 @@ | ||
import { isGramPathlike } from '@gram-data/gram-ast'; | ||
import { isGramPath } from '@gram-data/gram-ast'; | ||
@@ -62,3 +62,3 @@ function _extends() { | ||
visit(tree, function (element) { | ||
if (isGramPathlike(element)) { | ||
if (isGramPath(element)) { | ||
switch (mergedSettings.kind) { | ||
@@ -65,0 +65,0 @@ case 'numeric': |
@@ -26,14 +26,2 @@ (function (global, factory) { | ||
/** | ||
* # Gram AST Types | ||
* | ||
* These AST elements | ||
* | ||
* References: | ||
* | ||
* - [unist](https://github.com/syntax-tree/unist) - Universal Synax Tree | ||
* - [AST](https://en.wikipedia.org/wiki/Abstract_syntax_tree) | ||
* @packageDocumentation | ||
*/ | ||
/** | ||
* Type guard for a Path. | ||
@@ -44,2 +32,3 @@ * | ||
var isGramPath = function isGramPath(o) { | ||
@@ -49,61 +38,2 @@ return !!o.type && o.type === 'path'; | ||
var EMPTY_PATH_ID = 'ø'; | ||
/** | ||
* Type guard for GramEmptyPath. | ||
* | ||
* In practice both nodes and empty paths both have no children. | ||
* The distinguishing feature is that all empty paths have | ||
* no labels, no record, and always has the identity `ø`, while | ||
* a node may have labels, a record and always has an identity | ||
* other than `ø`. | ||
* | ||
* @param o any object | ||
*/ | ||
var isGramEmptyPath = function isGramEmptyPath(o) { | ||
return isGramPath(o) && o.children === undefined && o.id === EMPTY_PATH_ID; | ||
}; | ||
/** | ||
* Type guard for GramNode. | ||
* | ||
* In practice both nodes and empty paths both have no children. | ||
* The distinguishing feature is that all empty paths have | ||
* no labels, no record, and always has the identity `ø`, while | ||
* a node may have labels, a record and always has an identity | ||
* other than `ø`. | ||
* | ||
* @param o any object | ||
*/ | ||
var isGramNode = function isGramNode(o) { | ||
return isGramPath(o) && o.children && o.children.length === 0 && o.id !== EMPTY_PATH_ID; | ||
}; | ||
/** | ||
* Type guard for GramEdge. | ||
* | ||
* @param o any object | ||
*/ | ||
var isGramEdge = function isGramEdge(o) { | ||
return isGramPath(o) && o.relation !== undefined && o.relation !== 'pair' && o.children !== undefined && o.children.every(function (child) { | ||
return isGramNode(child); | ||
}); | ||
}; | ||
/** | ||
* Type guard for GramPathSequence. | ||
* | ||
* @param o any object | ||
*/ | ||
var isGramPathSequence = function isGramPathSequence(o) { | ||
return !!o.type && o.type === 'seq'; | ||
}; | ||
var isGramPathlike = function isGramPathlike(o) { | ||
return isGramPath(o) || isGramEmptyPath(o) || isGramNode(o) || isGramEdge(o) || isGramPathSequence(o); | ||
}; | ||
var shortid = /*#__PURE__*/require('shortid'); | ||
@@ -150,3 +80,3 @@ | ||
visit(tree, function (element) { | ||
if (isGramPathlike(element)) { | ||
if (isGramPath(element)) { | ||
switch (mergedSettings.kind) { | ||
@@ -153,0 +83,0 @@ case 'numeric': |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(((e=e||self).gram=e.gram||{},e.gram.identity={}))}(this,(function(e){"use strict";function n(){return(n=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e}).apply(this,arguments)}var r=function(e){return!!e.type&&"path"===e.type},t=function(e){return r(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"),c={kind:"numeric"};e.alphabets=a,e.gramIdentityPlugin=function(e){void 0===e&&(e=c);var i=n({},c,e);return function(e){var n=0;s(e,(function(e){if(r(a=e)||function(e){return r(e)&&void 0===e.children&&"ø"===e.id}(a)||t(a)||function(e){return r(e)&&void 0!==e.relation&&"pair"!==e.relation&&void 0!==e.children&&e.children.every((function(e){return t(e)}))}(a)||function(e){return!!e.type&&"seq"===e.type}(a))switch(i.kind){case"numeric":e.id=e.id||""+n++;break;case"shortid":e.id=e.id||o()}var a}))}},e.shortID=o,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(((e=e||self).gram=e.gram||{},e.gram.identity={}))}(this,(function(e){"use strict";function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e}).apply(this,arguments)}var r=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_@"};r.characters(a.base64);var i=r.generate,n=require("unist-util-visit"),s={kind:"numeric"};e.alphabets=a,e.gramIdentityPlugin=function(e){void 0===e&&(e=s);var r=t({},s,e);return function(e){var t=0;n(e,(function(e){if((a=e).type&&"path"===a.type)switch(r.kind){case"numeric":e.id=e.id||""+t++;break;case"shortid":e.id=e.id||i()}var a}))}},e.shortID=i,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=gram-identity.umd.production.min.js.map |
@@ -8,3 +8,3 @@ { | ||
], | ||
"version": "0.2.9", | ||
"version": "0.2.10", | ||
"license": "MIT", | ||
@@ -52,3 +52,3 @@ "repository": { | ||
"devDependencies": { | ||
"@gram-data/gram-parse": "^0.2.9", | ||
"@gram-data/gram-parse": "^0.2.10", | ||
"@types/jest": "^26.0.15", | ||
@@ -70,3 +70,3 @@ "@types/shortid": "^0.0.29", | ||
"dependencies": { | ||
"@gram-data/gram-ast": "^0.2.9", | ||
"@gram-data/gram-ast": "^0.2.10", | ||
"shortid": "^2.2.16", | ||
@@ -80,3 +80,3 @@ "unified": "^9.2.0", | ||
}, | ||
"gitHead": "1ff6bdb1c799a29a95540314bdb5b2a881971774" | ||
"gitHead": "5ab0f6f900db922abaf69906f62d6cf23e12215e" | ||
} |
@@ -6,3 +6,3 @@ import { Plugin, Transformer } from 'unified'; | ||
import { isGramPathlike } from '@gram-data/gram-ast'; | ||
import { isGramPath } from '@gram-data/gram-ast'; | ||
import { shortID } from './gram-identity'; | ||
@@ -27,3 +27,3 @@ const visit = require('unist-util-visit'); | ||
visit(tree, (element: UnistNode) => { | ||
if (isGramPathlike(element)) { | ||
if (isGramPath(element)) { | ||
switch (mergedSettings.kind) { | ||
@@ -30,0 +30,0 @@ case 'numeric': |
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 not supported yet
Sorry, the diff of this file is not supported yet
32541
322
Updated@gram-data/gram-ast@^0.2.10