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

typal

Package Overview
Dependencies
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typal - npm Package Compare versions

Comparing version 1.15.2 to 1.15.3

36

build/lib/index.js

@@ -93,2 +93,35 @@ /**

/**
* @param {string} d
*/
const trimD = d => {
d = d.trimRight()
const m = /\S/.exec(d)
if (!m) return d
const i = m.index
if (i == 0) return d
const s = d.substr(0, i)
let n = s.lastIndexOf('\n')
// remove everything before first /n
if (n == -1) n = 0
else {
n++
d = d.substr(n)
}
const ws = i - n
const w = ' '.repeat(ws)
const dd = d.split('\n')
const a = dd.filter(b => /\S/.test(b))
const notWithSpace = a.find(b => {
const res = !b.startsWith(w)
return res
})
if (!notWithSpace) {
const re = new RegExp(`^ {${ws}}`)
return dd.map(b => b.replace(re, '')).join('\n')
} else return d.trim()
}
module.exports.getNameWithDefault = getNameWithDefault

@@ -100,2 +133,3 @@ module.exports.getPropType = getPropType

module.exports.addSuppress = addSuppress
module.exports.getExternDeclaration = getExternDeclaration
module.exports.getExternDeclaration = getExternDeclaration
module.exports.trimD = trimD

13

build/lib/Property.js

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

const { getPropType, getNameWithDefault, makeOptional } = require('./');
const { getPropType, getNameWithDefault, makeOptional, trimD } = require('./');

@@ -43,2 +43,7 @@ /**

this.optional = false
/**
* What aliases the property has.
* @type {!Array<string>}
*/
this.aliases = []
}

@@ -51,7 +56,7 @@ static fromXML(...args) {

fromXML(content,
{ 'name': name, 'string': string, 'boolean': boolean, 'opt': opt, 'number': number, 'type': type, 'default': def, 'closure': closure },
{ 'name': name, 'string': string, 'boolean': boolean, 'opt': opt, 'number': number, 'type': type, 'default': def, 'closure': closure, 'alias': alias, 'aliases': aliases },
) {
if (!name) throw new Error('Property does not have a name.')
this.name = name
if (content) this.description = content.trim()
if (content) this.description = trimD(content)
const t = getPropType({ number, string, boolean, type })

@@ -64,2 +69,4 @@ this.type = t

if (opt || this.hasDefault) this.optional = true
if (alias) this.aliases = [alias]
if (aliases) this.aliases = aliases.split(/\s*,\s*/)
}

@@ -66,0 +73,0 @@ toJSDoc(parentParam = null, closure = false) {

const extractTags = require('rexml');
const parse = require('@typedefs/parser');
const Property = require('./Property');
const { getLink, addSuppress, makeBlock, getExternDeclaration, makeOptional } = require('./');
const { addSuppress, makeBlock, getExternDeclaration, makeOptional } = require('./');
const { getLink, trimD } = require('./');

@@ -83,3 +84,3 @@ /**

else this.closureType = this.type
if (desc) this.description = desc.trim()
if (desc) this.description = trimD(desc)
this.noToc = !!noToc

@@ -250,3 +251,3 @@ this.spread = !!spread

toMarkdown(allTypes = [], opts = {}) {
const { narrow, flatten } = opts
const { narrow, flatten, preprocessDesc } = opts
const t = this.type ? `\`${this.type}\`` : ''

@@ -279,2 +280,8 @@ const typeWithLink = this.link ? `[${t}](${this.link})` : t

e += `href="${foundExt.link}">\`${this.extends}\`</a>`
} else {
e = getLinks(allTypes, this.extends, { flatten,
nameProcess(td) {
return `\`${td}\``
} })
useTag = useTag || /_/.test(e)
}

@@ -294,3 +301,8 @@ const extendS = ` extends ${e}`

LINE += d
const table = makePropsTable(this.properties, allTypes, { narrow, flatten })
const table = makePropsTable(this.properties, allTypes, {
narrow,
flatten,
preprocessDesc,
})
if (narrow) return { LINE, table }
const r = `${LINE}${table}`

@@ -326,5 +338,8 @@ return r

* @param {string} type
* @param {boolean} flatten
* @param {Object} [opts]
* @param {boolean} [opts.flatten]
* @param {boolean} [opts.escapePipe]
* @param {boolean} [opts.nameProcess]
*/
const getLinks = (allTypes, type, flatten = false) => {
const getLinks = (allTypes, type, opts = {}) => {
let parsed

@@ -341,3 +356,3 @@ try {

if (!parsed) return type
const s = parsedToString(parsed, allTypes, flatten)
const s = parsedToString(parsed, allTypes, opts)
return s

@@ -349,5 +364,7 @@ }

* @param {!Array<!Type>} allTypes
* @param {boolean} [flatten] If the type has link, follow it.
* @param {Object} [opts] Options
* @param {boolean} [opts.flatten] If the type has link, follow it.
*/
const parsedToString = (type, allTypes, flatten) => {
const parsedToString = (type, allTypes, opts = {}) => {
const { escapePipe = true } = opts
let s = ''

@@ -357,3 +374,3 @@ let nullable = ''

else if (type.nullable === false) nullable = '!'
const p2s = (arg) => parsedToString(arg, allTypes, flatten)
const p2s = (arg) => parsedToString(arg, allTypes, opts)

@@ -400,3 +417,3 @@ if (type.function) {

} else if (type.application) {
s += getTypeWithLink(type.name, allTypes, nullable, flatten) + '&lt;'
s += getTypeWithLink(type.name, allTypes, nullable, opts) + '&lt;'
const apps = type.application.map((a) => {

@@ -413,7 +430,7 @@ return p2s(a)

})
s += union.join(' \\| ')
s += union.join(escapePipe ? ' \\| ' : ' | ')
s += ')'
} else {
const name = type.name == 'any' ? '*' : type.name
s += getTypeWithLink(name, allTypes, nullable, flatten)
s += getTypeWithLink(name, allTypes, nullable, opts)
}

@@ -423,3 +440,4 @@ return s

const getTypeWithLink = (type, allTypes, nullable = '', flatten = false) => {
const getTypeWithLink = (type, allTypes, nullable = '', opts = {}) => {
const { flatten = false, nameProcess } = opts
const l = getLinkToType(allTypes, type)

@@ -438,4 +456,5 @@ const n = `${nullable}${type}`

}
if (!description) return `[${n}](${link})`
return `<a href="${link}" title="${description}">${n}</a>`
const nn = nameProcess ? nameProcess(n) : n
if (!description) return `[${nn}](${link})`
return `<a href="${link}" title="${description}">${nn}</a>`
// const typeWithLink = `[${n}](#${link})`

@@ -452,34 +471,55 @@ // return typeWithLink

*/
const makePropsTable = (props = [], allTypes = [], { narrow = false, flatten = false } = {}) => {
const makePropsTable = (props = [], allTypes = [], { narrow = false, flatten = false, preprocessDesc } = {}) => {
if (!props.length) return ''
const anyHaveDefault = props.some(({ hasDefault }) => hasDefault)
const h = ['Name', ...(narrow ? ['Type & Description'] : ['Type', 'Description']), 'Default']
const h = ['Name',
...(narrow ? ['Type & Description'] : ['Type', 'Description']),
...(anyHaveDefault ? ['Default'] : [])]
const ps = props.map((prop) => {
const linkedType =
getLinks(/** @type {!Array<!Type>} */ (allTypes), prop.type, flatten)
const name = prop.optional ? prop.name : `__${prop.name}*__`
const typeName =
getLinks(/** @type {!Array<!Type>} */ (allTypes), prop.type, {
flatten,
escapePipe: !narrow,
})
const name = prop.optional ? prop.name : `${prop.name}*`
const d = !prop.hasDefault ? '-' : `\`${prop.default}\``
return [name,
...(narrow ?
[`<em>${linkedType}</em><br>${esc(prop.description)}`] :
[`<em>${linkedType}</em>`, esc(prop.description)])
, d]
const de = preprocessDesc ? preprocessDesc(prop.description) : prop.description
return {
prop,
typeName,
name,
de: esc(de, !narrow),
d,
}
})
const pre = [h, ...ps]
const res = anyHaveDefault
? pre
: pre.map(p => { p.pop(); return p })
const j = JSON.stringify(res, null, 2)
return `
if (narrow) { // narrow is the newer API for Documentary
return { props: ps, anyHaveDefault }
} else {
const ar = ps.map(({
name, typeName, de, d, prop,
}) => {
const n = prop.optional ? name : `__${name}__`
return [n, `<em>${typeName}</em>`, de, ...(anyHaveDefault ? [d] : [])]
})
const j = JSON.stringify([h, ...ar], null, 2)
return `
\`\`\`table
${j}
\`\`\``
}
}
const esc = (s = '') => {
// const li = (p) => {
// return p.replace(/(^\s*)- (.+)$/mg, `$1<li>$2</li>`)
// }
const esc = (s = '', escapePipe = true) => {
if (s === null) s = ''
if (escapePipe) {
s = s.replace(/\|/g, '\\|')
}
return s
.replace(/\|/g, '\\|')
.replace(/</g, '&lt;')

@@ -486,0 +526,0 @@ .replace(/>/, '&gt;')

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

## 24 July 2019
### [1.15.3](https://github.com/artdecocode/typal/compare/v1.15.2...v1.15.3)
- [feature] Better trimming of info from XML files.
- [feature] Aliases to types.
- [feature] Narrow table for _Documentary_.
## 22 July 2019

@@ -2,0 +10,0 @@

@@ -7,2 +7,26 @@ #!/usr/bin/env node

const path = require('path');
var aa = "function" == typeof Object.defineProperties ? Object.defineProperty : function(a, b, c) {
a != Array.prototype && a != Object.prototype && (a[b] = c.value);
}, ba = "undefined" != typeof window && window === this ? this : "undefined" != typeof global && null != global ? global : this;
function da(a, b) {
if (b) {
var c = ba;
a = a.split(".");
for (var d = 0; d < a.length - 1; d++) {
var e = a[d];
e in c || (c[e] = {});
c = c[e];
}
a = a[a.length - 1];
d = c[a];
b = b(d);
b != d && null != b && aa(c, a, {configurable:!0, writable:!0, value:b});
}
}
da("String.prototype.trimRight", function(a) {
function b() {
return this.replace(/[\s\xa0]+$/, "");
}
return a || b;
});
const u = (a, b, c, d, e) => {

@@ -26,3 +50,3 @@ d = void 0 === d ? !1 : d;

return {value:c, argv:[...a.slice(0, b), ...a.slice(d + 1)]};
}, aa = a => {
}, ea = a => {
const b = [];

@@ -37,3 +61,3 @@ for (let c = 0; c < a.length; c++) {

return b;
}, ca = () => {
}, fa = () => {
var a = v;

@@ -53,8 +77,8 @@ return Object.keys(a).reduce((b, c) => {

};
const v = {source:{description:"The path to the source file or directory with files to embed types into.", command:!0, multiple:!0}, output:{description:"The destination where to save output.\nIf not passed, the file will be overwritten.\nIf `-` is passed, prints to stdout.", short:"o"}, closure:{description:"Whether to generate types in _Closure_ mode.", boolean:!0, short:"c"}, externs:{description:"Whether to generate externs for _GCC_.", boolean:!0, short:"e"}, types:{description:"Comma-separated location of files to read types from.",
short:"t"}, migrate:{description:"Extracts types from JavaScript source code and saves them\ninto the types.xml file specified in the output option.", boolean:!0, short:"m"}, help:{description:"Print the help information and exit.", boolean:!0, short:"h"}, version:{description:"Show the version's number and exit.", boolean:!0, short:"v"}}, y = function(a, b) {
const v = {source:{description:"The path to the source file or directory with files to embed types into. Can specify multiple values, e.g., `typal types/index.js types/vendor.js`.", command:!0, multiple:!0}, output:{description:"The destination where to save output.\nIf not passed, the file will be overwritten.\nIf `-` is passed, prints to stdout.", short:"o"}, closure:{description:"Whether to generate types in _Closure_ mode.", boolean:!0, short:"c"}, externs:{description:"Whether to generate externs for _GCC_.",
boolean:!0, short:"e"}, types:{description:"Comma-separated location of files to read types from.", short:"t"}, migrate:{description:"Extracts types from JavaScript source code and saves them\ninto the types.xml file specified in the output option.", boolean:!0, short:"m"}, help:{description:"Print the help information and exit.", boolean:!0, short:"h"}, version:{description:"Show the version's number and exit.", boolean:!0, short:"v"}}, y = function(a, b) {
a = void 0 === a ? {} : a;
b = void 0 === b ? process.argv : b;
[, , ...b] = b;
const c = aa(b);
const c = ea(b);
b = b.slice(c.length);

@@ -83,4 +107,4 @@ let d = !c.length;

}, {m:b});
}(v), z = y.source, A = y.output, da = y.closure, ea = y.externs, fa = y.types, ha = y.migrate, ia = y.help, ja = y.version;
function ka(a = {usage:{}}) {
}(v), z = y.source, A = y.output, ha = y.closure, ia = y.externs, ja = y.types, ka = y.migrate, la = y.help, ma = y.version;
function na(a = {usage:{}}) {
const {usage:b = {}, description:c, line:d, example:e} = a;

@@ -116,5 +140,5 @@ a = Object.keys(b);

}
;const {createReadStream:la, createWriteStream:ma, lstat:B, readdir:na} = fs;
var oa = stream;
const {Transform:C, Writable:pa} = stream;
;const {createReadStream:oa, createWriteStream:pa, lstat:B, readdir:qa} = fs;
var ra = stream;
const {Transform:C, Writable:sa} = stream;
const D = (a, b = 0, c = !1) => {

@@ -126,9 +150,9 @@ if (0 === b && !c) {

return c ? a[a.length - 1] : a.slice(b).join("\n");
}, qa = (a, b = !1) => D(a, 2 + (b ? 1 : 0)), E = a => {
}, ta = (a, b = !1) => D(a, 2 + (b ? 1 : 0)), E = a => {
({callee:{caller:a}} = a);
return a;
};
const {homedir:ra} = os;
const F = /\s+at.*(?:\(|\s)(.*)\)?/, sa = /^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:IGNORED_MODULES)\/.*)?\w+)\.js:\d+:\d+)|native)/, ta = ra(), G = a => {
const {pretty:b = !1, ignoredModules:c = ["pirates"]} = {}, d = c.join("|"), e = new RegExp(sa.source.replace("IGNORED_MODULES", d));
const {homedir:ua} = os;
const F = /\s+at.*(?:\(|\s)(.*)\)?/, va = /^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:IGNORED_MODULES)\/.*)?\w+)\.js:\d+:\d+)|native)/, wa = ua(), G = a => {
const {pretty:b = !1, ignoredModules:c = ["pirates"]} = {}, d = c.join("|"), e = new RegExp(va.source.replace("IGNORED_MODULES", d));
return a.replace(/\\/g, "/").split("\n").filter(f => {

@@ -141,5 +165,5 @@ f = f.match(F);

return f.includes(".app/Contents/Resources/electron.asar") || f.includes(".app/Contents/Resources/default_app.asar") ? !1 : !e.test(f);
}).filter(f => f.trim()).map(f => b ? f.replace(F, (g, h) => g.replace(h, h.replace(ta, "~"))) : f).join("\n");
}).filter(f => f.trim()).map(f => b ? f.replace(F, (g, h) => g.replace(h, h.replace(wa, "~"))) : f).join("\n");
};
function ua(a, b, c = !1) {
function xa(a, b, c = !1) {
return function(d) {

@@ -156,6 +180,6 @@ var e = E(arguments), {stack:f} = Error();

const c = E(arguments);
b = qa(b, a);
return ua(c, b, a);
b = ta(b, a);
return xa(c, b, a);
}
;const va = (a, b) => {
;const ya = (a, b) => {
b.once("error", c => {

@@ -166,3 +190,3 @@ a.emit("error", c);

};
class wa extends pa {
class za extends sa {
constructor(a) {

@@ -192,3 +216,3 @@ var b = a || {}, c = Object.assign({}, b);

});
e && va(this, e).pipe(this);
e && ya(this, e).pipe(this);
});

@@ -206,7 +230,7 @@ }

var b = void 0 === b ? {} : b;
({i:a} = new wa(Object.assign({}, {rs:a}, b, {M:H(!0)})));
({i:a} = new za(Object.assign({}, {rs:a}, b, {M:H(!0)})));
return await a;
};
async function J(a) {
a = la(a);
a = oa(a);
return await I(a);

@@ -218,3 +242,3 @@ }

}
const c = H(!0), d = ma(a);
const c = H(!0), d = pa(a);
await new Promise((e, f) => {

@@ -251,3 +275,3 @@ d.on("error", g => {

;const {join:N} = path;
async function xa(a, b) {
async function Aa(a, b) {
b = b.map(async c => {

@@ -259,3 +283,3 @@ const d = N(a, c);

}
const ya = a => a.lstat.isDirectory(), za = a => !a.lstat.isDirectory();
const Ba = a => a.lstat.isDirectory(), Ca = a => !a.lstat.isDirectory();
async function O(a) {

@@ -268,6 +292,6 @@ if (!a) {

}
var b = await M(na, a);
b = await xa(a, b);
a = b.filter(ya);
b = b.filter(za).reduce((c, d) => {
var b = await M(qa, a);
b = await Aa(a, b);
a = b.filter(Ba);
b = b.filter(Ca).reduce((c, d) => {
var e = d.lstat.isDirectory() ? "Directory" : d.lstat.isFile() ? "File" : d.lstat.isSymbolicLink() ? "SymbolicLink" : void 0;

@@ -307,3 +331,3 @@ return Object.assign({}, c, {[d.relativePath]:{type:e}});

return `${a}=${b}`;
}, Aa = ({number:a, P:b, boolean:c, type:d}) => b ? "string" : a ? "number" : c ? "boolean" : d ? d : "*", R = a => `${/[^\w\d._]/.test(a) ? `(${a})` : a}|undefined`, Ba = a => `/**
}, Da = ({number:a, P:b, boolean:c, type:d}) => b ? "string" : a ? "number" : c ? "boolean" : d ? d : "*", R = a => `${/[^\w\d._]/.test(a) ? `(${a})` : a}|undefined`, Ea = a => `/**
${a}

@@ -316,4 +340,26 @@ */

return a;
}, U = a => {
a = a.trimRight();
var b = /\S/.exec(a);
if (!b) {
return a;
}
b = b.index;
if (0 == b) {
return a;
}
var c = a.substr(0, b).lastIndexOf("\n");
-1 == c ? c = 0 : (c++, a = a.substr(c));
b -= c;
const d = " ".repeat(b);
c = a.split("\n");
if (c.filter(e => /\S/.test(e)).find(e => !e.startsWith(d))) {
return a.trim();
}
{
const e = new RegExp(`^ {${b}}`);
return c.map(f => f.replace(e, "")).join("\n");
}
};
function U(a, b, c) {
function V(a, b, c) {
const d = [];

@@ -333,8 +379,8 @@ b.replace(a, (e, ...f) => {

}
;const V = new RegExp(`${/([^\s>=/]+)/.source}(?:\\s*=\\s*${/(?:"([\s\S]*?)"|'([\s\S]*?)')/.source})?`, "g"), Ca = new RegExp(`\\s*((?:${V.source}\\s*)*)`);
const W = (a, b) => U(new RegExp(`<${a}${Ca.source}?(?:${/\s*\/>/.source}|${(new RegExp(`>([\\s\\S]+?)?</${a}>`)).source})`, "g"), b, ["a", "v", "v1", "v2", "c"]).map(({a:c = "", c:d = ""}) => {
;const W = new RegExp(`${/([^\s>=/]+)/.source}(?:\\s*=\\s*${/(?:"([\s\S]*?)"|'([\s\S]*?)')/.source})?`, "g"), Fa = new RegExp(`\\s*((?:${W.source}\\s*)*)`);
const X = (a, b) => V(new RegExp(`<${a}${Fa.source}?(?:${/\s*\/>/.source}|${(new RegExp(`>([\\s\\S]+?)?</${a}>`)).source})`, "g"), b, ["a", "v", "v1", "v2", "c"]).map(({a:c = "", c:d = ""}) => {
c = c.replace(/\/$/, "").trim();
c = Da(c);
c = Ga(c);
return {content:d, B:c};
}), Da = a => U(V, a, ["key", "val", "def", "f"]).reduce((b, {key:c, val:d}) => {
}), Ga = a => V(W, a, ["key", "val", "def", "f"]).reduce((b, {key:c, val:d}) => {
if (!d) {

@@ -346,3 +392,3 @@ return b[c] = !0, b;

}, {});
const Ea = a => a.split(/([!?=*(),:.<>{}|\s+])/g).filter(b => /\S/.test(b)).map(b => {
const Ha = a => a.split(/([!?=*(),:.<>{}|\s+])/g).filter(b => /\S/.test(b)).map(b => {
switch(b) {

@@ -364,3 +410,3 @@ case "function":

});
function Fa(a) {
function Ia(a) {
let b = 0;

@@ -471,3 +517,3 @@ const c = (d, e) => {

b++;
":" == a[b] && (b++, k = c(), g.return = k);
":" == a[b] && (b++, k = c(), void 0 == k.name && k.nullable && (k.name = ""), g.return = k);
h.function = g;

@@ -514,7 +560,7 @@ } else {

}
;function Ga(a) {
a = Ea(a);
return Fa(a);
;function Ja(a) {
a = Ha(a);
return Ia(a);
}
;function Ha(a, b, {name:c, string:d, "boolean":e, opt:f, number:g, type:h, "default":k, closure:l}) {
;function Ka(a, b, {name:c, string:d, "boolean":e, opt:f, number:g, type:h, "default":k, closure:l}) {
if (!c) {

@@ -524,4 +570,4 @@ throw Error("Property does not have a name.");

a.name = c;
b && (a.description = b.trim());
a.type = Aa({number:g, P:d, boolean:e, type:h});
b && (a.description = U(b));
a.type = Da({number:g, P:d, boolean:e, type:h});
l ? a.f = l : a.f = a.type;

@@ -534,3 +580,3 @@ void 0 !== k && (a.b = !0);

}
function X(a, b = null, c = !1) {
function La(a, b = null, c = !1) {
if (!a.name) {

@@ -542,6 +588,6 @@ throw Error("Property does not have a name. Has it been constructed using fromXML?");

}
function Ia(a, b = !1) {
return ` * @prop ${X(a, null, b)}`;
function Ma(a, b = !1) {
return ` * @prop ${La(a, null, b)}`;
}
class Ja {
class Na {
constructor() {

@@ -556,7 +602,7 @@ this.description = this.name = null;

H(a, b = "", c = !1) {
a = X(this, a, c);
a = La(this, a, c);
return `${b} * @param ${a}`;
}
}
;function Ka(a, b, {name:c, type:d, desc:e, noToc:f, spread:g, noExpand:h, "import":k, link:l, closure:m, constructor:n, "extends":p, "interface":q, record:r}, t) {
;function Oa(a, b, {name:c, type:d, desc:e, noToc:f, spread:g, noExpand:h, "import":k, link:l, closure:m, constructor:n, "extends":p, "interface":q, record:r}, t) {
if (!c) {

@@ -568,3 +614,3 @@ throw Error("Type does not have a name.");

m ? a.f = m : a.f = a.type;
e && (a.description = e.trim());
e && (a.description = U(e));
a.J = !!f;

@@ -579,10 +625,10 @@ a.I = !!g;

p && (a.extends = p);
b && (a.h = W("prop", b).map(({content:w, B:x}) => {
const ba = new Ja;
Ha(ba, w, x);
return ba;
b && (a.h = X("prop", b).map(({content:w, B:x}) => {
const ca = new Na;
Ka(ca, w, x);
return ca;
}));
t && (a.l = t);
}
function La(a) {
function Pa(a) {
var b = [];

@@ -614,9 +660,9 @@ a.description && b.push(` * ${a.description}`);

}
function Ma(a, b) {
function Qa(a, b) {
const c = `${a.extends ? "$" : ""}${a.name}`;
return b ? `${a.u}${c}` : c;
}
function Na(a, b, c) {
var d = ` * @typedef {${(b ? a.f : a.type) || "Object"}}${` ${Ma(a, b)}${a.i}`}`;
a = a.h ? a.h.map(e => Ia(e, b)) : [];
function Ra(a, b, c) {
var d = ` * @typedef {${(b ? a.f : a.type) || "Object"}}${` ${Qa(a, b)}${a.i}`}`;
a = a.h ? a.h.map(e => Ma(e, b)) : [];
d = [d, ...a].join("\n");

@@ -629,4 +675,4 @@ b && !c && (d = S(d));

}
function Oa(a, b = !1, c = !1) {
const d = !!a.extends, e = Na(a, b, c), f = [];
function Sa(a, b = !1, c = !1) {
const d = !!a.extends, e = Ra(a, b, c), f = [];
if (a.l && b) {

@@ -641,3 +687,3 @@ let g = ` * @typedef {${a.g}} ${a.name}${a.i}`;

}
d && (a = ` * @typedef {${a.extends} & ${Ma(a, b)}} ${b ? a.g : a.name}${a.i}`, b && !c && (a = S(a)), a = `/**
d && (a = ` * @typedef {${a.extends} & ${Qa(a, b)}} ${b ? a.g : a.name}${a.i}`, b && !c && (a = S(a)), a = `/**
${a}

@@ -684,3 +730,3 @@ */

d = this.description ? ` ${this.description}` : "";
const g = this.I ? Pa(this.h) : e ? this.g : this.name;
const g = this.I ? Ta(this.h) : e ? this.g : this.name;
b = `${c || ""} * @param {${f}${g}} ${b ? `[${a}]` : a}${d}`;

@@ -691,3 +737,3 @@ f = this.h && !this.A ? this.h.map(h => h.H(a, c, e)) : [];

}
const Pa = (a = [], b = !1) => `{ ${a.map(c => {
const Ta = (a = [], b = !1) => `{ ${a.map(c => {
const d = b ? c.f : c.type;

@@ -698,3 +744,3 @@ let e = c.name, f = d;

}).join(", ")} }`;
function Qa(a) {
function Ua(a) {
if ("object" != typeof a) {

@@ -708,3 +754,3 @@ return !1;

}
const Ra = (a, b) => {
const Va = (a, b) => {
if (!(b instanceof Error)) {

@@ -723,10 +769,10 @@ throw b;

};
async function Sa(a, b) {
b instanceof oa ? b.pipe(a) : a.end(b);
async function Wa(a, b) {
b instanceof ra ? b.pipe(a) : a.end(b);
return await I(a);
}
class Ta extends C {
class Xa extends C {
constructor(a, b) {
super(b);
this.o = (Array.isArray(a) ? a : [a]).filter(Qa);
this.o = (Array.isArray(a) ? a : [a]).filter(Ua);
this.b = !1;

@@ -736,5 +782,5 @@ this.A = b;

async replace(a, b) {
const c = new Ta(this.o, this.A);
const c = new Xa(this.o, this.A);
b && Object.assign(c, b);
a = await Sa(c, a);
a = await Wa(c, a);
c.b && this.brake();

@@ -770,3 +816,3 @@ b && Object.keys(b).forEach(d => {

} catch (l) {
Ra(f, l);
Va(f, l);
}

@@ -779,3 +825,3 @@ });

} catch (h) {
Ra(f, h);
Va(f, h);
}

@@ -799,4 +845,4 @@ } else {

}
;function Ua() {
var a = Va;
;function Ya() {
var a = Za;
let b = "";

@@ -812,3 +858,3 @@ const c = new C({transform(d, e, f) {

}
;function Wa(a, {name:b, from:c, desc:d, link:e, ns:f}) {
;function $a(a, {name:b, from:c, desc:d, link:e, ns:f}) {
a.name = b;

@@ -820,6 +866,6 @@ a.from = c;

}
function Xa(a, b = !0) {
function ab(a, b = !0) {
return ` * @typedef {import('${a.from}').${a.name}} ${b ? a.g : a.name}`;
}
class Ya {
class bb {
constructor() {

@@ -833,7 +879,7 @@ this.from = this.name = this.u = "";

}
;function Za(a, b) {
;function cb(a, b) {
b = b.reduce((c, d) => Object.assign({}, c, {[d.g]:d}), {});
a.C = Object.assign({}, a.C, b);
}
class $a extends Ta {
class db extends Xa {
constructor(a, b) {

@@ -844,3 +890,3 @@ b = void 0 === b ? {} : b;

this.on("types", c => {
Za(this, c);
cb(this, c);
});

@@ -860,3 +906,3 @@ this.on("namespace", c => {

static get b() {
return Ya;
return bb;
}

@@ -867,4 +913,4 @@ get types() {

}
;const ab = a => {
a = W("types", a);
;const eb = a => {
a = X("types", a);
if (!a.length) {

@@ -874,14 +920,14 @@ throw Error("XML file should contain root types element.");

const [{content:b, B:{namespace:c, ns:d = c}}] = a, e = void 0 == d ? void 0 : d;
a = W("type", b).map(({content:h, B:k}) => {
a = X("type", b).map(({content:h, B:k}) => {
const l = new Y;
Ka(l, h, k, e);
Oa(l, h, k, e);
return l;
});
const f = W("import", b).map(({B:h}) => {
const k = new Ya;
Wa(k, h);
const f = X("import", b).map(({B:h}) => {
const k = new bb;
$a(k, h);
return k;
}), g = f.map(({name:h, from:k, D:l, link:m, u:n}) => {
const p = new Y;
Ka(p, "", {name:h, type:`import('${k}').${h}`, J:!0, import:!0, D:l, link:m}, void 0 == n ? void 0 : n);
Oa(p, "", {name:h, type:`import('${k}').${h}`, J:!0, import:!0, D:l, link:m}, void 0 == n ? void 0 : n);
return p;

@@ -891,6 +937,6 @@ });

};
const bb = (a, b, c) => {
b = b.map(d => Oa(d, !0, c));
const fb = (a, b, c) => {
b = b.map(d => Sa(d, !0, c));
a = a.map(d => {
d = Xa(d);
d = ab(d);
return `/**

@@ -902,11 +948,11 @@ ${c ? d : S(d)}

return [...b, ...a].join("");
}, cb = (a, b, c, d = !1) => {
}, gb = (a, b, c, d = !1) => {
a = [...a.map(e => {
{
let f;
e.f ? f = ` * @typedef {${e.f}}` : e.O || (f = ` * @typedef {${Pa(e.h, !0)}}`);
e.f ? f = ` * @typedef {${e.f}}` : e.O || (f = ` * @typedef {${Ta(e.h, !0)}}`);
f ? (e.description && (f = ` * ${e.description}\n${f}`), f = `/**
${f}
*/
`, e = f += T(e.l, e.name)) : e = La(e);
`, e = f += T(e.l, e.name)) : e = Pa(e);
}

@@ -919,3 +965,3 @@ return e;

};
const eb = {re:/^\/\*\*? (documentary|typal) (.+?) \*\/\n(?:([^\n][\s\S]+?\n))?$/mg, replacement:async function(a, b, c) {
const ib = {re:/^\/\*\*? (documentary|typal) (.+?) \*\/\n(?:([^\n][\s\S]+?\n))?$/mg, replacement:async function(a, b, c) {
const [d, ...e] = c.split(/\s+/), f = e.includes("closure"), g = e.includes("externs"), h = e.includes("noSuppress"), k = e.includes("skipNsDecl");

@@ -930,3 +976,3 @@ let l = e.find(p => p.startsWith("ignore:"));

const p = await J(d);
let {l:q = null, types:r, imports:t} = ab(p);
let {l:q = null, types:r, imports:t} = eb(p);
r = r.filter(({g:x}) => l.includes(x) ? !1 : !0);

@@ -937,3 +983,3 @@ t = t.filter(({g:x}) => l.includes(x) ? !1 : !0);

let w;
m ? w = bb(t, r, h) : n ? (w = cb(r, q, this.i, k) + "\n", q && this.emit("namespace", q)) : w = db(t, r);
m ? w = fb(t, r, h) : n ? (w = gb(r, q, this.i, k) + "\n", q && this.emit("namespace", q)) : w = hb(t, r);
return `/* ${b} ${c} */\n${w}`;

@@ -943,10 +989,10 @@ } catch (p) {

}
}}, db = (a, b) => {
b = b.map(c => Oa(c));
a = a.map(c => Xa(c, !1)).map(Ba).join("");
}}, hb = (a, b) => {
b = b.map(c => Sa(c));
a = a.map(c => ab(c, !1)).map(Ea).join("");
b = b.join("");
return `${a}${b}`.replace(fb, " * @typedef");
}, fb = / \*\/\n\/\*\*\n \* @typedef/g;
const hb = {re:/( *) \* @param {(.+?)} (\[)?([^\s\]]+)\]?(?: .+)?((?:\n(?: +)\* @param {(?:.+?)} \[?\4\]?.*)*)/gm, replacement:gb};
function gb(a, b, c, d, e, f, g) {
return `${a}${b}`.replace(jb, " * @typedef");
}, jb = / \*\/\n\/\*\*\n \* @typedef/g;
const lb = {re:/( *) \* @param {(.+?)} (\[)?([^\s\]]+)\]?(?: .+)?((?:\n(?: +)\* @param {(?:.+?)} \[?\4\]?.*)*)/gm, replacement:kb};
function kb(a, b, c, d, e, f, g) {
const {w:h} = this.s;

@@ -969,3 +1015,3 @@ let k;

try {
k = Ga(c);
k = Ja(c);
} catch (m) {

@@ -982,3 +1028,3 @@ return this.j("Error while parsing the type %s", c), this.j(process.env.DEBUG ? m.stack : m.message), f(), a;

c = Object.values(this.types).find(({name:m, g:n}) => h ? n == k.name : m == k.name);
return c instanceof $a.b ? a : c.H(e, d, b, k.nullable, h);
return c instanceof db.b ? a : c.H(e, d, b, k.nullable, h);
}

@@ -1009,4 +1055,4 @@ const Z = (a, b, c, d, e) => {

};
var jb = async() => {
const {w:a = !1, F:b = !1, G:c, types:d} = {w:da, F:ea, G:A, types:fa};
var nb = async() => {
const {w:a = !1, F:b = !1, G:c, types:d} = {w:ha, F:ia, G:A, types:ja};
await Promise.all(z.map(async e => {

@@ -1016,10 +1062,10 @@ var f = await M(B, e);

f.isFile() ? g = [e] : f.isDirectory() && (f = await O(e), g = P(f.content, e));
await ib(g, a, b, c, d);
await mb(g, a, b, c, d);
}));
};
const ib = async(a, b = !1, c = !1, d = null, e = null) => {
const mb = async(a, b = !1, c = !1, d = null, e = null) => {
const f = [];
e && await Promise.all(e.split(",").map(async g => {
g = await J(g);
const {types:h, imports:k} = ab(g);
const {types:h, imports:k} = eb(g);
f.push(h, k);

@@ -1029,3 +1075,3 @@ }));

var h = await J(g);
const k = new $a([eb, hb], {w:b, F:c});
const k = new db([ib, lb], {w:b, F:c});
f.forEach(l => k.emit("types", l));

@@ -1040,7 +1086,7 @@ k.file = g;

};
const kb = a => {
const ob = a => {
let b;
"true" == a ? b = !0 : "false" == a ? b = !1 : /^\d+$/.test(a) && (b = parseInt(a, 10));
return void 0 !== b ? b : a;
}, lb = /^ \* @prop {(.+?)} (\[)?(.+?)(?:=(["'])?(.+?)\4)?(?:])?(?: (.+?))?(?: Default `(.+?)`.)?$/gm, mb = "type opt name quote defaultValue description Default".split(" "), Va = new RegExp(`^ \\* @typedef {(.+?)} (.+?)(?: (.+))?\\n((?:${/ \* @prop(?:erty)? .+\n/.source})*)`, "gm"), nb = (a, b, c, d) => {
}, pb = /^ \* @prop {(.+?)} (\[)?(.+?)(?:=(["'])?(.+?)\4)?(?:])?(?: (.+?))?(?: Default `(.+?)`.)?$/gm, qb = "type opt name quote defaultValue description Default".split(" "), Za = new RegExp(`^ \\* @typedef {(.+?)} (.+?)(?: (.+))?\\n((?:${/ \* @prop(?:erty)? .+\n/.source})*)`, "gm"), rb = (a, b, c, d) => {
d = d.length;

@@ -1051,3 +1097,3 @@ a = a && "Object" != a ? ` type="${a}"` : "";

};
class ob extends C {
class sb extends C {
constructor() {

@@ -1058,3 +1104,3 @@ super({writableObjectMode:!0});

var {type:d, name:e, description:f, h:g} = a;
a = d && d.startsWith("import") ? pb(d, e) : nb(d, e, f, g);
a = d && d.startsWith("import") ? tb(d, e) : rb(d, e, f, g);
this.push(a);

@@ -1077,3 +1123,3 @@ g.forEach(h => {

}
const pb = (a, b) => {
const tb = (a, b) => {
const c = /import\((['"])(.+?)\1\)/.exec(a);

@@ -1086,3 +1132,3 @@ if (!c) {

};
class qb extends C {
class ub extends C {
constructor() {

@@ -1093,3 +1139,3 @@ super({objectMode:!0});

var [, d, e, f, g] = a;
a = U(lb, g, mb).map(h => {
a = V(pb, g, qb).map(h => {
var k = Object.assign({}, h), l = h.defaultValue;

@@ -1101,3 +1147,3 @@ const m = h.Default;

k = (delete k.defaultValue, delete k.Default, delete k.opt, delete k.name, delete k.type, k);
n = Object.assign({}, k, {name:p, type:h}, l ? {defaultValue:kb(l)} : {}, m ? {v:kb(m)} : {}, n ? {optional:!0} : {});
n = Object.assign({}, k, {name:p, type:h}, l ? {defaultValue:ob(l)} : {}, m ? {v:ob(m)} : {}, n ? {optional:!0} : {});
if (l || m) {

@@ -1112,4 +1158,4 @@ l ? l !== m && void 0 !== n.v && (l = Q(p, m, h), console.error("%s[%s] does not match Default `%s`.", e, l, n.v)) : (l = Q(p, m, h), console.error("%s[%s] got from Default.", e, l)), n.default = "defaultValue" in n ? n.defaultValue : n.v, delete n.defaultValue, delete n.v;

}
async function rb(a) {
const b = Ua(), c = new qb, d = new ob;
async function vb(a) {
const b = Ya(), c = new ub, d = new sb;
b.pipe(c).pipe(d);

@@ -1133,20 +1179,20 @@ b.end(a);

}
;var sb = async() => {
;var wb = async() => {
const {G:a} = {G:A};
await Promise.all(z.map(async b => {
b = await J(b);
b = await rb(b);
b = await vb(b);
a ? await K(a, b) : console.log(b);
}));
};
if (ia) {
const a = ca();
console.log(ka({usage:a, description:"Embeds and maintains Closure-compatible types JSDoc in\nJavaScript source code from an external types.xml file.", line:"typal source [--closure|externs] [--migrate] [-o output] [-hv]", example:"typal src/index.js -c"}));
if (la) {
const a = fa();
console.log(na({usage:a, description:"Embeds and maintains Closure-compatible types JSDoc in\nJavaScript source code from an external types.xml file.", line:"typal source [--closure|externs] [--migrate] [-o output] [-hv]", example:"typal src/index.js -c"}));
process.exit();
} else {
ja && (console.log(require("../../package.json").version), process.exit());
ma && (console.log(require("../../package.json").version), process.exit());
}
(async() => {
try {
return ha ? await sb() : await jb();
return ka ? await wb() : await nb();
} catch (a) {

@@ -1153,0 +1199,0 @@ process.env.DEBUG ? console.log(a.stack) : console.log(a.message);

{
"name": "typal",
"version": "1.15.2",
"version": "1.15.3",
"description": "Organises TypeDefs By Placing Them Into Types.Xml File To Be Embedded Into Source Code Compatible With VSCode And Google Closure Compiler, Generates Externs And Allows To Place Documentation In README Markdown.",

@@ -72,5 +72,5 @@ "main": "build/index.js",

"alamode": "^2.3.4",
"argufy": "^1.7.0",
"argufy": "^1.7.1",
"catchment": "^3.3.0",
"documentary": "^1.27.3",
"documentary": "^1.27.7",
"erotic": "^2.1.1",

@@ -87,3 +87,3 @@ "eslint-config-artdeco": "1.0.1",

"dependencies": {
"@typedefs/parser": "^1.3.0",
"@typedefs/parser": "^1.3.1",
"mismatch": "^1.2.0",

@@ -90,0 +90,0 @@ "rexml": "^2.0.2"

@@ -5,3 +5,3 @@ import argufy from 'argufy'

'source': {
description: 'The path to the source file or directory with files to embed types into.',
description: 'The path to the source file or directory with files to embed types into. Can specify multiple values, e.g., `typal types/index.js types/vendor.js`.',
command: true,

@@ -47,3 +47,3 @@ multiple: true,

/**
* The path to the source file or directory with files to embed types into.
* The path to the source file or directory with files to embed types into. Can specify multiple values, e.g., `typal types/index.js types/vendor.js`.
*/

@@ -50,0 +50,0 @@ export const _source = /** @type {(!Array<string>|string)} */ (args['source'])

@@ -91,2 +91,35 @@ /**

return res
}
/**
* @param {string} d
*/
export const trimD = d => {
d = d.trimRight()
const m = /\S/.exec(d)
if (!m) return d
const i = m.index
if (i == 0) return d
const s = d.substr(0, i)
let n = s.lastIndexOf('\n')
// remove everything before first /n
if (n == -1) n = 0
else {
n++
d = d.substr(n)
}
const ws = i - n
const w = ' '.repeat(ws)
const dd = d.split('\n')
const a = dd.filter(b => /\S/.test(b))
const notWithSpace = a.find(b => {
const res = !b.startsWith(w)
return res
})
if (!notWithSpace) {
const re = new RegExp(`^ {${ws}}`)
return dd.map(b => b.replace(re, '')).join('\n')
} else return d.trim()
}

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

import { getPropType, getNameWithDefault, makeOptional } from './'
import { getPropType, getNameWithDefault, makeOptional, trimD } from './'

@@ -43,2 +43,7 @@ /**

this.optional = false
/**
* What aliases the property has.
* @type {!Array<string>}
*/
this.aliases = []
}

@@ -51,7 +56,7 @@ static fromXML(...args) {

fromXML(content,
{ 'name': name, 'string': string, 'boolean': boolean, 'opt': opt, 'number': number, 'type': type, 'default': def, 'closure': closure },
{ 'name': name, 'string': string, 'boolean': boolean, 'opt': opt, 'number': number, 'type': type, 'default': def, 'closure': closure, 'alias': alias, 'aliases': aliases },
) {
if (!name) throw new Error('Property does not have a name.')
this.name = name
if (content) this.description = content.trim()
if (content) this.description = trimD(content)
const t = getPropType({ number, string, boolean, type })

@@ -64,2 +69,4 @@ this.type = t

if (opt || this.hasDefault) this.optional = true
if (alias) this.aliases = [alias]
if (aliases) this.aliases = aliases.split(/\s*,\s*/)
}

@@ -66,0 +73,0 @@ toJSDoc(parentParam = null, closure = false) {

import extractTags from 'rexml'
import parse from '@typedefs/parser'
import Property from './Property'
import { getLink, addSuppress, makeBlock, getExternDeclaration, makeOptional } from './'
import { addSuppress, makeBlock, getExternDeclaration, makeOptional } from './'
import { getLink, trimD } from './'

@@ -83,3 +84,3 @@ /**

else this.closureType = this.type
if (desc) this.description = desc.trim()
if (desc) this.description = trimD(desc)
this.noToc = !!noToc

@@ -250,3 +251,3 @@ this.spread = !!spread

toMarkdown(allTypes = [], opts = {}) {
const { narrow, flatten } = opts
const { narrow, flatten, preprocessDesc } = opts
const t = this.type ? `\`${this.type}\`` : ''

@@ -279,2 +280,8 @@ const typeWithLink = this.link ? `[${t}](${this.link})` : t

e += `href="${foundExt.link}">\`${this.extends}\`</a>`
} else {
e = getLinks(allTypes, this.extends, { flatten,
nameProcess(td) {
return `\`${td}\``
} })
useTag = useTag || /_/.test(e)
}

@@ -294,3 +301,8 @@ const extendS = ` extends ${e}`

LINE += d
const table = makePropsTable(this.properties, allTypes, { narrow, flatten })
const table = makePropsTable(this.properties, allTypes, {
narrow,
flatten,
preprocessDesc,
})
if (narrow) return { LINE, table }
const r = `${LINE}${table}`

@@ -326,5 +338,8 @@ return r

* @param {string} type
* @param {boolean} flatten
* @param {Object} [opts]
* @param {boolean} [opts.flatten]
* @param {boolean} [opts.escapePipe]
* @param {boolean} [opts.nameProcess]
*/
export const getLinks = (allTypes, type, flatten = false) => {
export const getLinks = (allTypes, type, opts = {}) => {
let parsed

@@ -341,3 +356,3 @@ try {

if (!parsed) return type
const s = parsedToString(parsed, allTypes, flatten)
const s = parsedToString(parsed, allTypes, opts)
return s

@@ -349,5 +364,7 @@ }

* @param {!Array<!Type>} allTypes
* @param {boolean} [flatten] If the type has link, follow it.
* @param {Object} [opts] Options
* @param {boolean} [opts.flatten] If the type has link, follow it.
*/
const parsedToString = (type, allTypes, flatten) => {
const parsedToString = (type, allTypes, opts = {}) => {
const { escapePipe = true } = opts
let s = ''

@@ -357,3 +374,3 @@ let nullable = ''

else if (type.nullable === false) nullable = '!'
const p2s = (arg) => parsedToString(arg, allTypes, flatten)
const p2s = (arg) => parsedToString(arg, allTypes, opts)

@@ -400,3 +417,3 @@ if (type.function) {

} else if (type.application) {
s += getTypeWithLink(type.name, allTypes, nullable, flatten) + '&lt;'
s += getTypeWithLink(type.name, allTypes, nullable, opts) + '&lt;'
const apps = type.application.map((a) => {

@@ -413,7 +430,7 @@ return p2s(a)

})
s += union.join(' \\| ')
s += union.join(escapePipe ? ' \\| ' : ' | ')
s += ')'
} else {
const name = type.name == 'any' ? '*' : type.name
s += getTypeWithLink(name, allTypes, nullable, flatten)
s += getTypeWithLink(name, allTypes, nullable, opts)
}

@@ -423,3 +440,4 @@ return s

const getTypeWithLink = (type, allTypes, nullable = '', flatten = false) => {
const getTypeWithLink = (type, allTypes, nullable = '', opts = {}) => {
const { flatten = false, nameProcess } = opts
const l = getLinkToType(allTypes, type)

@@ -438,4 +456,5 @@ const n = `${nullable}${type}`

}
if (!description) return `[${n}](${link})`
return `<a href="${link}" title="${description}">${n}</a>`
const nn = nameProcess ? nameProcess(n) : n
if (!description) return `[${nn}](${link})`
return `<a href="${link}" title="${description}">${nn}</a>`
// const typeWithLink = `[${n}](#${link})`

@@ -452,34 +471,55 @@ // return typeWithLink

*/
export const makePropsTable = (props = [], allTypes = [], { narrow = false, flatten = false } = {}) => {
export const makePropsTable = (props = [], allTypes = [], { narrow = false, flatten = false, preprocessDesc } = {}) => {
if (!props.length) return ''
const anyHaveDefault = props.some(({ hasDefault }) => hasDefault)
const h = ['Name', ...(narrow ? ['Type & Description'] : ['Type', 'Description']), 'Default']
const h = ['Name',
...(narrow ? ['Type & Description'] : ['Type', 'Description']),
...(anyHaveDefault ? ['Default'] : [])]
const ps = props.map((prop) => {
const linkedType =
getLinks(/** @type {!Array<!Type>} */ (allTypes), prop.type, flatten)
const name = prop.optional ? prop.name : `__${prop.name}*__`
const typeName =
getLinks(/** @type {!Array<!Type>} */ (allTypes), prop.type, {
flatten,
escapePipe: !narrow,
})
const name = prop.optional ? prop.name : `${prop.name}*`
const d = !prop.hasDefault ? '-' : `\`${prop.default}\``
return [name,
...(narrow ?
[`<em>${linkedType}</em><br>${esc(prop.description)}`] :
[`<em>${linkedType}</em>`, esc(prop.description)])
, d]
const de = preprocessDesc ? preprocessDesc(prop.description) : prop.description
return {
prop,
typeName,
name,
de: esc(de, !narrow),
d,
}
})
const pre = [h, ...ps]
const res = anyHaveDefault
? pre
: pre.map(p => { p.pop(); return p })
const j = JSON.stringify(res, null, 2)
return `
if (narrow) { // narrow is the newer API for Documentary
return { props: ps, anyHaveDefault }
} else {
const ar = ps.map(({
name, typeName, de, d, prop,
}) => {
const n = prop.optional ? name : `__${name}__`
return [n, `<em>${typeName}</em>`, de, ...(anyHaveDefault ? [d] : [])]
})
const j = JSON.stringify([h, ...ar], null, 2)
return `
\`\`\`table
${j}
\`\`\``
}
}
const esc = (s = '') => {
// const li = (p) => {
// return p.replace(/(^\s*)- (.+)$/mg, `$1<li>$2</li>`)
// }
const esc = (s = '', escapePipe = true) => {
if (s === null) s = ''
if (escapePipe) {
s = s.replace(/\|/g, '\\|')
}
return s
.replace(/\|/g, '\\|')
.replace(/</g, '&lt;')

@@ -486,0 +526,0 @@ .replace(/>/, '&gt;')

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