Comparing version 1.0.0-alpha to 1.0.0-alpha.1
@@ -26,2 +26,3 @@ const parseArguments = require('parse-fn-args') | ||
if (name == 'evaluate') throw new Error("Name 'evaluate' is reserved") | ||
if (name == 'namespace') throw new Error("Name 'namespace' is reserved") | ||
if (name[0] == '_') throw new Error(`Bad name '${name}'. Names begining with underscore are reserved`) | ||
@@ -75,3 +76,3 @@ if (name[name.length - 1] == '$') throw new Error( | ||
app = ns | ||
ns = '' | ||
ns = null | ||
} | ||
@@ -99,2 +100,9 @@ | ||
if (def.ns) { | ||
def.ns = add_namespace(ns, def.ns) | ||
} else { | ||
def.ns = ns | ||
} | ||
this.defs[add_namespace(ns, key)] = def | ||
@@ -116,4 +124,12 @@ } | ||
App.prototype.compile = function(main) { | ||
let app = analyze(this.defs, main) | ||
App.prototype._analyze = function(main, seeds) { | ||
let defs = clone(this.defs) | ||
let root = main + '$' // Some reserved name | ||
defs[root] = {main, seeds: seeds || []} | ||
return analyze(defs, root) | ||
} | ||
App.prototype.compile = function(main, seeds) { | ||
let app = this._analyze(main, seeds) | ||
let js = generate(app) | ||
@@ -130,6 +146,6 @@ let fn = new Function('rt', 'defs', js) | ||
App.prototype.printJS = function(main) { | ||
let app = analyze(this.defs, main) | ||
App.prototype.printJS = function(main, seeds) { | ||
let app = this._analyze(main, seeds) | ||
let js = generate(app) | ||
console.log(js) | ||
} |
@@ -135,2 +135,4 @@ | ||
rhs = `rt.getEval(this, '${name}')` | ||
} else if (dep == 'namespace') { | ||
rhs = `this._ns_${name}` | ||
} else if (def.lazy[dep]) { | ||
@@ -199,2 +201,3 @@ rhs = `rt.getLazy(this, this._get_${dep})` | ||
out.line(`_${level.name}.prototype._uses_${name} = defs.${name}.uses`) | ||
out.line(`_${level.name}.prototype._ns_${name} = defs.${name}.ns || null`) | ||
} | ||
@@ -201,0 +204,0 @@ |
@@ -54,2 +54,3 @@ const forOwn = require('lodash.forown') | ||
this.pre = opts.pre || [] | ||
this.ns = opts.ns | ||
@@ -72,3 +73,3 @@ this.uses = (opts.uses || []).reduce(function(uses, name) { | ||
Fn.prototype.forEachDependency = function(cb) { | ||
let call_cb = unique(cb) | ||
let call_cb = unique(cb, {evaluate: true, namespace: true}) | ||
forOwn(this.uses, (mapping, name) => call_cb(mapping)) | ||
@@ -80,6 +81,7 @@ this.pre.forEach(call_cb) | ||
function unique(cb) { | ||
function unique(cb, forbidden) { | ||
forbidden = forbidden || {} | ||
let seen = {} | ||
return function(i) { | ||
if (seen[i]) return | ||
if (seen[i] || forbidden[i]) return | ||
seen[i] = true | ||
@@ -86,0 +88,0 @@ cb(i) |
{ | ||
"name": "easy-app", | ||
"version": "1.0.0-alpha", | ||
"version": "1.0.0-alpha.1", | ||
"description": "Powerful container for applications", | ||
@@ -5,0 +5,0 @@ "author": "Eldar Gabdullin <eldargab@gmail.com>", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
19706
569
1