Comparing version 1.27.0 to 1.27.1
@@ -0,1 +1,9 @@ | ||
## 12 April 2020 | ||
### [1.27.1](https://gitlab.com/artdeco/typal/compare/v1.27.0...v1.27.1) | ||
- [fix] Print async return type of a method in namespaces' `@typedef`. | ||
- [fix] Correctly add properties with hyphens. | ||
- [fix] Add _RegExp_ to the globals when checking types. | ||
## 7 April 2020 | ||
@@ -2,0 +10,0 @@ |
@@ -121,3 +121,3 @@ #!/usr/bin/env node | ||
f = f.filter(g => null !== g); | ||
Object.assign(a, {Y:f}); | ||
Object.assign(a, {Z:f}); | ||
return a; | ||
@@ -210,6 +210,6 @@ }(ha), x = q.source, z = q.output, ja = q.closure, ka = q.useNamespace, la = q.externs, ma = q.types, na = q.template, oa = q.migrate, pa = q.version; | ||
constructor(a) { | ||
const {binary:b = !1, rs:c = null, ...d} = a || {}, {R:e = F(!0), proxyError:f} = a || {}, g = (h, l) => e(l); | ||
const {binary:b = !1, rs:c = null, ...d} = a || {}, {S:e = F(!0), proxyError:f} = a || {}, g = (h, l) => e(l); | ||
super(d); | ||
this.b = []; | ||
this.N = new Promise((h, l) => { | ||
this.O = new Promise((h, l) => { | ||
this.on("finish", () => { | ||
@@ -239,7 +239,7 @@ let k; | ||
get f() { | ||
return this.N; | ||
return this.O; | ||
} | ||
} | ||
const G = async a => { | ||
({f:a} = new Fa({rs:a, R:F(!0)})); | ||
({f:a} = new Fa({rs:a, S:F(!0)})); | ||
return await a; | ||
@@ -378,3 +378,3 @@ }; | ||
;const Qa = a => new RegExp(`%%_RESTREAM_${a.toUpperCase()}_REPLACEMENT_(\\d+)_%%`, "g"), Ra = (a, b) => `%%_RESTREAM_${a.toUpperCase()}_REPLACEMENT_${b}_%%`, Sa = () => { | ||
var a = {S:/^\/\*\*? (documentary|typal) (.+?) externs (.*?)\*\/\r?\n(?:([^\r\n][\s\S]+?\r?\n))?$/mg}; | ||
var a = {T:/^\/\*\*? (documentary|typal) (.+?) externs (.*?)\*\/\r?\n(?:([^\r\n][\s\S]+?\r?\n))?$/mg}; | ||
return Object.keys(a).reduce((b, c) => { | ||
@@ -499,6 +499,9 @@ { | ||
return `${a}=${b}`; | ||
}, ab = ({number:a, L:b, boolean:c, type:d}) => b ? "string" : a ? "number" : c ? "boolean" : d ? d : "*", bb = a => `${/[^\w\d._]/.test(a) ? `(${a})` : a}|undefined`, M = a => a ? `/**${C}${a}${C} */${C}` : `/**${C} */${C}`, N = a => ` * @suppress {nonStandardJsDocs}${C}${a}`, cb = (a, b, c) => { | ||
a = `${a ? "" : "var "}${a ? `${a}.` : ""}${b}`; | ||
c && (a += ` = ${c}`); | ||
return a; | ||
}, ab = ({number:a, M:b, boolean:c, type:d}) => b ? "string" : a ? "number" : c ? "boolean" : d ? d : "*", bb = a => `${/[^\w\d._]/.test(a) ? `(${a})` : a}|undefined`, M = a => a ? `/**${C}${a}${C} */${C}` : `/**${C} */${C}`, N = a => ` * @suppress {nonStandardJsDocs}${C}${a}`, cb = (a, b, c) => { | ||
let d = a ? `${a}.` : ""; | ||
a = a ? "" : "var "; | ||
b.includes("-") && (b = `['${b}']`, d = d.replace(/\.$/, "")); | ||
b = `${a}${d}${b}`; | ||
c && (b += ` = ${c}`); | ||
return b; | ||
}, db = a => { | ||
@@ -746,3 +749,3 @@ const b = a.split(/\r?\n/).map(c => { | ||
b && (a.description = Q(b)); | ||
b = ab({number:g, L:d, boolean:e, type:h}); | ||
b = ab({number:g, M:d, boolean:e, type:h}); | ||
l && (b = b.replace(new RegExp(`([!?])?${l}\\.`, "g"), "$1")); | ||
@@ -852,3 +855,3 @@ b.endsWith("=") && (b = b.replace(/=$/, ""), f = !0); | ||
} | ||
function sb(a, {O:b = !0, T:c = !0} = {}) { | ||
function sb(a, {P:b = !0, U:c = !0} = {}) { | ||
const d = []; | ||
@@ -889,3 +892,3 @@ b && d.push(" * @example"); | ||
c = `{${ub(a, c)}} ${b}${e}`; | ||
d && (a = sb(a.examples, {O:!1, T:!1}).join(C).replace(/\*/g, "\uff0a")) && (c += `${C}${a}`); | ||
d && (a = sb(a.examples, {P:!1, U:!1}).join(C).replace(/\*/g, "\uff0a")) && (c += `${C}${a}`); | ||
return c; | ||
@@ -904,3 +907,3 @@ } | ||
if (f) { | ||
const {M:h, X:l} = yb(a.args || []), k = [h, l].filter(Boolean).join(" "); | ||
const {N:h, Y:l} = yb(a.args || []), k = [h, l].filter(Boolean).join(" "); | ||
c.push(` * @param {...${T(f)}} ${k}`); | ||
@@ -925,3 +928,3 @@ } | ||
if (c) { | ||
const {M:e} = yb(a.args || []); | ||
const {N:e} = yb(a.args || []); | ||
d.push(`...${e}`); | ||
@@ -1004,3 +1007,3 @@ } | ||
a && (this.description = Q(a)); | ||
a = ab({number:f, L:c, boolean:d, type:g}); | ||
a = ab({number:f, M:c, boolean:d, type:g}); | ||
t && (this.s = t); | ||
@@ -1055,3 +1058,3 @@ l && (this.f = l); | ||
c.startsWith("...") && (b = c.replace("...", "")); | ||
return {M:b, X:d}; | ||
return {N:b, Y:d}; | ||
}; | ||
@@ -1090,6 +1093,6 @@ class W extends Bb { | ||
e = [...e, ...a]; | ||
const {G:f, K:g, n:h} = e.reduce((l, k) => { | ||
k.isConstructor ? l.G.push(k) : k.static ? l.K.push(k) : l.n.push(k); | ||
const {G:f, L:g, n:h} = e.reduce((l, k) => { | ||
k.isConstructor ? l.G.push(k) : k.static ? l.L.push(k) : l.n.push(k); | ||
return l; | ||
}, {G:[], K:[], n:[]}); | ||
}, {G:[], L:[], n:[]}); | ||
return {constructor:f[0] || null, properties:[...f, ...g, ...h]}; | ||
@@ -1174,3 +1177,3 @@ } | ||
const t = g || n.optional ? n.name : `${n.name}*`, r = n.hasDefault ? `\`${n.default}\`` : "-", u = f ? f(n.description) : n.description; | ||
return {prop:n, typeName:p, name:t, de:Hb(u, !e), d:r, Z:k}; | ||
return {prop:n, typeName:p, name:t, de:Hb(u, !e), d:r, $:k}; | ||
}); | ||
@@ -1278,3 +1281,3 @@ if (e) { | ||
} | ||
get u() { | ||
get K() { | ||
return this.isConstructor || this.isInterface || this.isRecord; | ||
@@ -1307,3 +1310,3 @@ } | ||
} | ||
get U() { | ||
get X() { | ||
const a = this.tag; | ||
@@ -1339,3 +1342,3 @@ if (!a) { | ||
}); | ||
b && d.push(` * @${this.U}`); | ||
b && d.push(` * @${this.X}`); | ||
c && this.examples.length && (b = sb(this.examples), d.push(...b)); | ||
@@ -1452,3 +1455,3 @@ a && (d = d.map(f => `${a}${f}`)); | ||
} | ||
get u() { | ||
get K() { | ||
return !1; | ||
@@ -1459,6 +1462,7 @@ } | ||
} | ||
b(a, {async:b, "return":c, ...d}, ...e) { | ||
b(a, {async:b, "return":c, "void":d, ...e}, ...f) { | ||
this.description = Q(a); | ||
super.b("", d, ...e); | ||
super.b("", e, ...f); | ||
c && (this.f = c.replace(/\r?\n\s*/g, " ")); | ||
d && (this.f = "void"); | ||
b && (this.async = !0); | ||
@@ -1470,11 +1474,14 @@ } | ||
h(a = "") { | ||
const b = super.h(a, !1); | ||
let c; | ||
this.f && (c = this.return); | ||
this.async && c ? c = `Promise<${c}>` : this.async && (c = "Promise"); | ||
const b = super.h(a, !1), c = this.u; | ||
c && b.push(`${a} * @return {${c}}`); | ||
return b; | ||
} | ||
get u() { | ||
let a = ""; | ||
this.f && (a = this.return); | ||
this.async && a ? a = `Promise<${a}>` : this.async && (a = "Promise"); | ||
return a; | ||
} | ||
s() { | ||
return `(${this.args.map(({name:a, type:b, optional:c}) => `${a}${c ? "?" : ""}: ${b}`).join(", ")}) => ${this.return}`; | ||
return `(${this.args.map(({name:a, type:b, optional:c}) => `${a}${c ? "?" : ""}: ${b}`).join(", ")}) => ${this.u}`; | ||
} | ||
@@ -1600,3 +1607,3 @@ m(a) { | ||
let f; | ||
e.closureType ? f = ` * @typedef {${e.closureType}}` : e.u || (f = ` * @typedef {${Nb(e.properties, !0)}}`); | ||
e.closureType ? f = ` * @typedef {${e.closureType}}` : e.K || (f = ` * @typedef {${Nb(e.properties, !0)}}`); | ||
f ? (e.description && (f = ` * ${e.description}${C}${f}`), f = M(f), e = f += cb(e.namespace, e.name)) : e = Jb(e); | ||
@@ -1659,5 +1666,5 @@ } | ||
} | ||
n = {line:n, P:b.length + 11}; | ||
n = {line:n, R:b.length + 11}; | ||
} | ||
const {line:p, P:t} = n; | ||
const {line:p, R:t} = n; | ||
this.i("%s:%s:%s", this.file, p, t); | ||
@@ -1706,5 +1713,5 @@ } | ||
} | ||
}, gc = "String Boolean Object Date Number Symbol Buffer Function".split(" "); | ||
}, gc = "String Boolean Object Date Number Symbol Buffer Function RegExp".split(" "); | ||
var mc = (a, b = !1) => { | ||
var {S:c} = Sa(); | ||
var {T:c} = Sa(); | ||
const d = Ua(c); | ||
@@ -1711,0 +1718,0 @@ c = Ta(c); |
@@ -579,3 +579,3 @@ #!/usr/bin/env node | ||
this.examples = []; | ||
this.f = null; | ||
this.g = null; | ||
} | ||
@@ -603,7 +603,7 @@ get import() { | ||
if (a) { | ||
const {properties:u, constructor:v} = ka(a, z, this.f, this.fullName); | ||
const {properties:u, constructor:v} = ka(a, z, this.g, this.fullName); | ||
v && (this.args = v.args); | ||
this.properties = u; | ||
} | ||
q && (a = {example:q}, L(a, this.f), this.examples = N(a.example, r)); | ||
q && (a = {example:q}, L(a, this.g), this.examples = N(a.example, r)); | ||
} | ||
@@ -650,3 +650,3 @@ h(a, b = new RegExp(`([!?])?${a}\\.`, "g")) { | ||
super(); | ||
this.g = null; | ||
this.f = null; | ||
this.async = !1; | ||
@@ -657,14 +657,15 @@ } | ||
} | ||
b(a, {async:b, "return":d, ...c}, ...f) { | ||
b(a, {async:b, "return":d, "void":c, ...f}, ...g) { | ||
this.description = J(a); | ||
super.b("", c, ...f); | ||
d && (this.g = d.replace(/\r?\n\s*/g, " ")); | ||
super.b("", f, ...g); | ||
d && (this.f = d.replace(/\r?\n\s*/g, " ")); | ||
c && (this.f = "void"); | ||
b && (this.async = !0); | ||
} | ||
get return() { | ||
return this.g || "void"; | ||
return this.f || "void"; | ||
} | ||
h(a) { | ||
a = super.h(a); | ||
this.g && (this.g = this.g.replace(a, "$1")); | ||
this.f && (this.f = this.f.replace(a, "$1")); | ||
} | ||
@@ -708,3 +709,3 @@ } | ||
const e = f ? new W : new U; | ||
e.f = g; | ||
e.g = g; | ||
g = a.search(/<(prop|function|fn|static) /); | ||
@@ -765,3 +766,3 @@ let k = "", h = a; | ||
p = new U; | ||
d && (p.f = d); | ||
d && (p.g = d); | ||
p.b(n, m, e, b); | ||
@@ -771,3 +772,3 @@ l.push(p); | ||
const v = new U; | ||
d && (v.f = d); | ||
d && (v.g = d); | ||
v.b(n, {...t, name:u}, e, b); | ||
@@ -774,0 +775,0 @@ l.push(v); |
{ | ||
"name": "typal", | ||
"version": "1.27.0", | ||
"version": "1.27.1", | ||
"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.", | ||
@@ -54,3 +54,3 @@ "main": "compile/index.js", | ||
"depack": "^1.1.2", | ||
"documentary": "^1.38.1", | ||
"documentary": "^1.38.4", | ||
"erotic": "^2.1.1", | ||
@@ -57,0 +57,0 @@ "erte": "^1.3.0", |
@@ -85,4 +85,8 @@ import { resolve, dirname } from 'path' | ||
export const getExternDeclaration = (namespace, name, constr) => { | ||
const ns = namespace ? `${namespace}.` : '' | ||
let ns = namespace ? `${namespace}.` : '' | ||
const v = namespace ? '' : 'var ' | ||
if (name.includes('-')) { | ||
name = `['${name}']` | ||
ns = ns.replace(/\.$/, '') | ||
} | ||
let res = `${v}${ns}${name}` | ||
@@ -89,0 +93,0 @@ if (constr) res = res + ` = ${constr}` |
@@ -24,3 +24,3 @@ import Type from './Type' | ||
} | ||
fromXML(content, { 'async': methodAsync, 'return': methodReturn, | ||
fromXML(content, { 'async': methodAsync, 'return': methodReturn, 'void': Void, | ||
...props | ||
@@ -31,2 +31,3 @@ }, ...args) { | ||
if (methodReturn) this._methodReturn = methodReturn.replace(/\r?\n\s*/g, ' ') | ||
if (Void) this._methodReturn = 'void' | ||
if (methodAsync) this.async = true | ||
@@ -45,6 +46,3 @@ } | ||
const lines = super.toHeading(ws, false) | ||
let r | ||
if (this._methodReturn) r = this.return | ||
if (this.async && r) r = `Promise<${r}>` | ||
else if (this.async) r = 'Promise' | ||
const r = this.ret | ||
if (r) lines.push(`${ws} * @return {${r}}`) | ||
@@ -54,2 +52,9 @@ | ||
} | ||
get ret() { | ||
let r = '' | ||
if (this._methodReturn) r = this.return | ||
if (this.async && r) r = `Promise<${r}>` | ||
else if (this.async) r = 'Promise' | ||
return r | ||
} | ||
/** | ||
@@ -64,3 +69,3 @@ * TypeScript-style type for typedefs. | ||
}).join(', ') | ||
}) => ${this.return}` | ||
}) => ${this.ret}` | ||
} | ||
@@ -67,0 +72,0 @@ clearNamespace(rootNamespace) { |
@@ -110,3 +110,3 @@ import parser from '@typedefs/parser' | ||
const API = ['String', 'Boolean', 'Object', 'Date', 'Number', | ||
'Symbol', 'Buffer', 'Function'] | ||
'Symbol', 'Buffer', 'Function', 'RegExp'] | ||
@@ -113,0 +113,0 @@ /** |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
519514
6198