Comparing version 1.24.12 to 1.24.13
## 18 December 2019 | ||
### [1.24.13](https://github.com/artdecocode/typal/compare/v1.24.12...v1.24.13) | ||
- [feature] Template no return. | ||
### [1.24.12](https://github.com/artdecocode/typal/compare/v1.24.11...v1.24.12) | ||
@@ -4,0 +8,0 @@ |
@@ -520,3 +520,3 @@ #!/usr/bin/env node | ||
({args:a = ""} = a); | ||
a || (a = b.map(({I:h, name:k}) => "this" == k ? `${k}: ${h}` : k.startsWith("...") ? `...${h}` : h).join(",")); | ||
a || (a = b.map(({J:h, name:k}) => "this" == k ? `${k}: ${h}` : k.startsWith("...") ? `...${h}` : h).join(",")); | ||
b = f.replace(/\n\s*/g, " "); | ||
@@ -527,3 +527,3 @@ d && b ? b = `!Promise<${b}>` : d && (b = "!Promise"); | ||
b && (c += `: ${b}`); | ||
return {W:{...g, async:d}, H:c}; | ||
return {W:{...g, async:d}, I:c}; | ||
}; | ||
@@ -757,3 +757,3 @@ function gb(a, b, c) { | ||
} | ||
get I() { | ||
get J() { | ||
return this.optional ? `${this.type}=` : this.type; | ||
@@ -770,3 +770,3 @@ } | ||
})); | ||
return {K:d, F:e}; | ||
return {K:d, G:e}; | ||
}; | ||
@@ -894,16 +894,21 @@ function S(a) { | ||
} | ||
function xb(a) { | ||
const b = [], {function:{args:c, return:d, variableArgs:e, this:f}} = a.parsed; | ||
c.map(h => S(h)).forEach((h, k) => { | ||
const {optional:l} = c[k], {name:m = `arg${k}`, description:n} = a.args[k] || {}; | ||
b.push(` * @param {${h}${l ? "=" : ""}} ${l ? `[${m}]` : m}${n ? ` ${n}` : ""}`); | ||
function xb(a, b) { | ||
const c = [], {function:{args:d, return:e, variableArgs:f, this:g}} = a.parsed; | ||
d.map(h => S(h)).forEach((h, k) => { | ||
const {optional:l} = d[k], {name:m = `arg${k}`, description:n} = a.args[k] || {}; | ||
c.push(` * @param {${h}${l ? "=" : ""}} ${l ? `[${m}]` : m}${n ? ` ${n}` : ""}`); | ||
}); | ||
if (e) { | ||
const {N:h, X:k} = yb(a.args || []); | ||
var g = [h, k].filter(Boolean).join(" "); | ||
b.push(` * @param {...${S(e)}} ${g}`); | ||
if (f) { | ||
const {N:h, X:k} = yb(a.args || []), l = [h, k].filter(Boolean).join(" "); | ||
c.push(` * @param {...${S(f)}} ${l}`); | ||
} | ||
f && b.push(` * @this {${S(f)}}`); | ||
d && "void" != d.name && (g = S(d), b.push(` * @return {${g}}`)); | ||
return b; | ||
g && c.push(` * @this {${S(g)}}`); | ||
if (e && "void" != e.name) { | ||
if (b && a.s) { | ||
return c; | ||
} | ||
b = S(e); | ||
c.push(` * @return {${b}}`); | ||
} | ||
return c; | ||
} | ||
@@ -928,3 +933,3 @@ function zb(a) { | ||
e && (e = T(e), d.push(...e.split("\n"))); | ||
!a.optional && a.isParsedFunction ? (e = xb(a), d.push(...e)) : d.push(` * @type {${a.optional ? db(a.closureType) : a.closureType}}`); | ||
!a.optional && a.isParsedFunction ? (e = xb(a, c), d.push(...e)) : d.push(` * @type {${a.optional ? db(a.closureType) : a.closureType}}`); | ||
c && a.examples.length && (a = sb(a.examples), d.push(...a)); | ||
@@ -952,2 +957,3 @@ b && (d = d.map(f => `${b}${f}`)); | ||
this.examples = []; | ||
this.s = !1; | ||
} | ||
@@ -987,3 +993,3 @@ toTypeScriptFunction(a) { | ||
} | ||
b(a, {name:b, string:c, "boolean":d, opt:e, number:f, type:g, "default":h, closure:k, alias:l, aliases:m, example:n, "example-override":p = "", noParams:q, "static":r, initial:t}) { | ||
b(a, {name:b, string:c, "boolean":d, opt:e, number:f, type:g, "default":h, closure:k, alias:l, aliases:m, example:n, "example-override":p = "", noParams:q, "static":r, initial:t, "template-no-return":u}) { | ||
if (!b) { | ||
@@ -1006,2 +1012,3 @@ throw Error("Property does not have a name."); | ||
n && (this.examples = rb(n, p)); | ||
u && (this.s = !0); | ||
} | ||
@@ -1034,3 +1041,3 @@ get type() { | ||
} | ||
C(a, b = "", c = !1) { | ||
D(a, b = "", c = !1) { | ||
a = vb(this, a, c); | ||
@@ -1236,5 +1243,5 @@ const [d, ...e] = a.split("\n"); | ||
G = "static" == G; | ||
const {K:$b, F:Ha} = pb(x, u); | ||
const {K:$b, G:Ha} = pb(x, u); | ||
x = new V(Ha); | ||
const {W:ha, H:ac} = fb(z, Ha, this.fullName); | ||
const {W:ha, I:ac} = fb(z, Ha, this.fullName); | ||
ha.type = ac; | ||
@@ -1247,6 +1254,6 @@ Gb(ha, this.file); | ||
a = [...b, ...a]; | ||
const {G:v, L:bc, n:cc} = a.reduce((x, z) => { | ||
z.isConstructor ? x.G.push(z) : z.static ? x.L.push(z) : x.n.push(z); | ||
const {H:v, L:bc, n:cc} = a.reduce((x, z) => { | ||
z.isConstructor ? x.H.push(z) : z.static ? x.L.push(z) : x.n.push(z); | ||
return x; | ||
}, {G:[], L:[], n:[]}); | ||
}, {H:[], L:[], n:[]}); | ||
this.properties = [...v, ...bc, ...cc]; | ||
@@ -1256,3 +1263,3 @@ } | ||
} | ||
get J() { | ||
get s() { | ||
return this.isConstructor || this.isInterface || this.isRecord; | ||
@@ -1325,3 +1332,3 @@ } | ||
} | ||
C(a, b, c, d, e = !1, f = !1) { | ||
D(a, b, c, d, e = !1, f = !1) { | ||
var g = ""; | ||
@@ -1332,3 +1339,3 @@ !0 === d ? g = "?" : !1 === d && (g = "!"); | ||
b = `${c || ""} * @param {${g}${h}} ${b ? `[${a}]` : a}${d}`; | ||
g = this.properties && !this.noExpand ? this.properties.map(k => k.C(a, c, e, f)) : []; | ||
g = this.properties && !this.noExpand ? this.properties.map(k => k.D(a, c, e, f)) : []; | ||
return [b, ...g].join("\n"); | ||
@@ -1399,3 +1406,3 @@ } | ||
b = b.reduce((c, d) => ({...c, [d.fullName]:d}), {}); | ||
a.w = {...a.w, ...b}; | ||
a.A = {...a.A, ...b}; | ||
} | ||
@@ -1405,3 +1412,3 @@ class Qb extends N { | ||
super(a); | ||
this.w = {}; | ||
this.A = {}; | ||
this.on("types", c => { | ||
@@ -1426,3 +1433,3 @@ Pb(this, c); | ||
get types() { | ||
return this.w; | ||
return this.A; | ||
} | ||
@@ -1436,3 +1443,3 @@ } | ||
} | ||
get J() { | ||
get s() { | ||
return !1; | ||
@@ -1476,3 +1483,3 @@ } | ||
var {args:c = []} = a; | ||
const d = `function(${c.map(({I:e}) => e).join(", ")}): ${a.fullName}`; | ||
const d = `function(${c.map(({J:e}) => e).join(", ")}): ${a.fullName}`; | ||
c = new V(c); | ||
@@ -1508,3 +1515,3 @@ c.isConstructor = !0; | ||
case "interface": | ||
m = Ub({content:l, props:m, ns:g, B:b, location:c}); | ||
m = Ub({content:l, props:m, ns:g, C:b, location:c}); | ||
m.forEach(u => { | ||
@@ -1517,3 +1524,3 @@ u.properties.some(({isConstructor:v}) => v) || Tb(u, b); | ||
case "constructor": | ||
m = Ub({content:l, props:m, ns:g, B:b, location:c}); | ||
m = Ub({content:l, props:m, ns:g, C:b, location:c}); | ||
m.forEach(u => { | ||
@@ -1526,3 +1533,3 @@ u.properties.some(({isConstructor:v}) => v) || Tb(u, b); | ||
case "method": | ||
m = Ub({content:l, props:m, ns:g, B:b, isMethod:!0, location:c}); | ||
m = Ub({content:l, props:m, ns:g, C:b, isMethod:!0, location:c}); | ||
k.push(...m); | ||
@@ -1543,9 +1550,9 @@ break; | ||
1 != f && (h = a.slice(0, f), k = a.slice(f)); | ||
const {F:l, K:m} = pb(h, d); | ||
const {G:l, K:m} = pb(h, d); | ||
g.b(e ? m : k, b, c, d); | ||
({H:a} = fb(b, l)); | ||
({I:a} = fb(b, l)); | ||
e && (g.closureType = a); | ||
g.args = l; | ||
return g; | ||
}, Ub = ({content:a, props:b, ns:c, B:d, isMethod:e = !1, location:f = null}) => { | ||
}, Ub = ({content:a, props:b, ns:c, C:d, isMethod:e = !1, location:f = null}) => { | ||
const g = [], {alias:h, aliases:k, ...l} = b; | ||
@@ -1583,3 +1590,3 @@ b = Wb(a, b, c, d, e, f); | ||
let f; | ||
e.closureType ? f = ` * @typedef {${e.closureType}}` : e.J || (f = ` * @typedef {${Lb(e.properties, !0)}}`); | ||
e.closureType ? f = ` * @typedef {${e.closureType}}` : e.s || (f = ` * @typedef {${Lb(e.properties, !0)}}`); | ||
f ? (e.description && (f = ` * ${e.description}\n${f}`), f = O(f), e = f += eb(e.namespace, e.name)) : e = Hb(e); | ||
@@ -1597,3 +1604,3 @@ } | ||
m = m ? m.replace("ignore:", "").split(",") : []; | ||
let {v:n, A:p} = this.g; | ||
let {w:n, B:p} = this.g; | ||
f && (n = !0); | ||
@@ -1620,3 +1627,3 @@ g && (p = !0); | ||
function gc(a, b, c, d, e, f, g) { | ||
const {v:h, D:k} = this.g; | ||
const {w:h, F:k} = this.g; | ||
let l; | ||
@@ -1650,3 +1657,3 @@ f = () => { | ||
c = Object.values(this.types).find(({name:n, fullName:p}) => h || k ? p == l.name : n == l.name); | ||
return !c || c instanceof Qb.Import ? a : c.C(e, d, b, l.nullable, h, k); | ||
return !c || c instanceof Qb.Import ? a : c.D(e, d, b, l.nullable, h, k); | ||
} | ||
@@ -1761,3 +1768,3 @@ const Z = (a, b, c, d, e) => { | ||
async function qc() { | ||
const {s:a, types:b} = {s:oa, types:na}, c = await oc(b), d = await pc(c); | ||
const {u:a, types:b} = {u:oa, types:na}, c = await oc(b), d = await pc(c); | ||
await Promise.all(y.map(async e => { | ||
@@ -1780,3 +1787,3 @@ var f = await I(A, e); | ||
var tc = async() => { | ||
const {v:a = !1, D:b = !1, A:c = !1, s:d, types:e} = {v:ka, A:ma, s:ja, types:na, D:la}, f = await oc(e); | ||
const {w:a = !1, F:b = !1, B:c = !1, u:d, types:e} = {w:ka, B:ma, u:ja, types:na, F:la}, f = await oc(e); | ||
await Promise.all(y.map(async g => { | ||
@@ -1798,3 +1805,3 @@ var h = await I(A, g); | ||
var k = await F(h); | ||
const l = jc({v:b, A:c, D:f}, c); | ||
const l = jc({w:b, B:c, F:f}, c); | ||
g.forEach(m => l.emit("types", m)); | ||
@@ -1857,6 +1864,6 @@ l.file = h; | ||
const {defaultValue:h, Default:k, opt:l, name:m, type:n, ...p} = g; | ||
g = {...p, name:m, type:n, ...h ? {defaultValue:uc(h)} : {}, ...k ? {u:uc(k)} : {}, ...l ? {optional:!0} : {}}; | ||
g = {...p, name:m, type:n, ...h ? {defaultValue:uc(h)} : {}, ...k ? {v:uc(k)} : {}, ...l ? {optional:!0} : {}}; | ||
if (h || k) { | ||
if (h) { | ||
h !== k && void 0 !== g.u && (q = bb(m, k, n), console.error("%s[%s] does not match Default `%s`.", b, q, g.u)); | ||
h !== k && void 0 !== g.v && (q = bb(m, k, n), console.error("%s[%s] does not match Default `%s`.", b, q, g.v)); | ||
} else { | ||
@@ -1866,5 +1873,5 @@ var q = bb(m, k, n); | ||
} | ||
g.default = "defaultValue" in g ? g.defaultValue : g.u; | ||
g.default = "defaultValue" in g ? g.defaultValue : g.v; | ||
delete g.defaultValue; | ||
delete g.u; | ||
delete g.v; | ||
} | ||
@@ -1898,3 +1905,3 @@ return g; | ||
;var Cc = async() => { | ||
const {s:a} = {s:ja}; | ||
const {u:a} = {u:ja}; | ||
await Promise.all(y.map(async b => { | ||
@@ -1901,0 +1908,0 @@ b = await F(b); |
{ | ||
"name": "typal", | ||
"version": "1.24.12", | ||
"version": "1.24.13", | ||
"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.", | ||
@@ -5,0 +5,0 @@ "main": "compile/index.js", |
@@ -112,2 +112,4 @@ import parse from '@typedefs/parser' | ||
this.examples = [] | ||
this.templateNoReturn = false | ||
} | ||
@@ -178,3 +180,5 @@ /** | ||
'aliases': aliases, 'example': example, 'example-override': exampleOverride = '', | ||
'noParams': noParams, 'static': Static, 'initial': initial }, | ||
'noParams': noParams, 'static': Static, 'initial': initial, | ||
'template-no-return': templateNoReturn, | ||
}, | ||
) { | ||
@@ -201,2 +205,3 @@ if (!name) throw new Error('Property does not have a name.') | ||
if (example) this.examples = Property.readExamples(example, exampleOverride) | ||
if (templateNoReturn) this.templateNoReturn = true | ||
} | ||
@@ -283,3 +288,3 @@ static readExamples(Example, exampleOverride = '') { | ||
*/ | ||
toHeading() { | ||
toHeading(fromTemplate) { | ||
const pp = [] | ||
@@ -304,2 +309,3 @@ const { function: { args, return: ret, variableArgs, this: thisType } } = this.parsed | ||
if (ret && ret.name != 'void') { // vs code assumes void with no return | ||
if (fromTemplate && this.templateNoReturn) return pp | ||
const r = serialise(ret) | ||
@@ -362,3 +368,3 @@ pp.push(` * @return {${r}}`) | ||
*/ | ||
toExtern(ws = '', includeExample = false) { | ||
toExtern(ws = '', fromTemplate = false) { | ||
let pp = [] | ||
@@ -371,3 +377,3 @@ const { descriptionWithDefault } = this | ||
if (!this.optional && this.isParsedFunction) { | ||
const lines = this.toHeading() | ||
const lines = this.toHeading(fromTemplate) | ||
pp.push(...lines) | ||
@@ -378,3 +384,3 @@ } else { | ||
} | ||
if (includeExample && this.examples.length) { | ||
if (fromTemplate && this.examples.length) { | ||
const el = Property.getExampleLines(this.examples) | ||
@@ -381,0 +387,0 @@ pp.push(...el) |
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
472929
5954