Comparing version 4.2.2 to 4.3.0
@@ -1,6 +0,5 @@ | ||
// Generated by CoffeeScript 1.12.4 | ||
// Generated by CoffeeScript 2.0.0-beta3 | ||
(function() { | ||
var CND, njs_fs, njs_path, njs_util, rpr, validate_isa_number, | ||
slice = [].slice, | ||
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; | ||
indexOf = [].indexOf; | ||
@@ -17,21 +16,14 @@ njs_path = require('path'); | ||
this.equals = function() { | ||
var P; | ||
P = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
return (require('./jkroso-equals')).apply(null, P); | ||
this.equals = function(...P) { | ||
return (require('./jkroso-equals'))(...P); | ||
}; | ||
this.deep_copy = function() { | ||
var P; | ||
P = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
return (require('./universal-copy')).apply(null, P); | ||
this.deep_copy = function(...P) { | ||
return (require('./universal-copy'))(...P); | ||
}; | ||
this.format_number = function(n, grouper) { | ||
var f, h; | ||
if (grouper == null) { | ||
grouper = "'"; | ||
} | ||
this.format_number = function(n, grouper = "'") { | ||
/* A simple number formatter. */ | ||
var f, h; | ||
n = n.toString(); | ||
@@ -99,7 +91,3 @@ f = function(n) { | ||
this.shuffle = function(list, ratio) { | ||
var this_idx; | ||
if (ratio == null) { | ||
ratio = 1; | ||
} | ||
this.shuffle = function(list, ratio = 1) { | ||
@@ -118,2 +106,3 @@ /* Shuffles the elements of a list randomly. After the call, the elements of will be—most of the time— | ||
*/ | ||
var this_idx; | ||
if ((this_idx = list.length) < 2) { | ||
@@ -125,10 +114,3 @@ return list; | ||
this.get_shuffle = function(seed_0, seed_1) { | ||
var random_integer, rnd; | ||
if (seed_0 == null) { | ||
seed_0 = 0; | ||
} | ||
if (seed_1 == null) { | ||
seed_1 = 1; | ||
} | ||
this.get_shuffle = function(seed_0 = 0, seed_1 = 1) { | ||
@@ -139,16 +121,12 @@ /* This method works similar to `get_rnd`; it accepts two `seed`s which are used to produce random number | ||
*/ | ||
var random_integer, rnd; | ||
rnd = this.get_rnd(seed_0); | ||
random_integer = this.get_rnd_int(seed_1); | ||
return (function(_this) { | ||
return function(list, ratio) { | ||
if (ratio == null) { | ||
ratio = 1; | ||
} | ||
return _this._shuffle(list, ratio, rnd, random_integer); | ||
}; | ||
})(this); | ||
return (list, ratio = 1) => { | ||
return this._shuffle(list, ratio, rnd, random_integer); | ||
}; | ||
}; | ||
this._shuffle = function(list, ratio, rnd, random_integer) { | ||
var ref, that_idx, this_idx; | ||
var that_idx, this_idx; | ||
if ((this_idx = list.length) < 2) { | ||
@@ -164,3 +142,3 @@ return list; | ||
that_idx = random_integer(0, this_idx); | ||
ref = [list[this_idx], list[that_idx]], list[that_idx] = ref[0], list[this_idx] = ref[1]; | ||
[list[that_idx], list[this_idx]] = [list[this_idx], list[that_idx]]; | ||
} | ||
@@ -178,9 +156,3 @@ } | ||
this.random_number = function(min, max) { | ||
if (min == null) { | ||
min = 0; | ||
} | ||
if (max == null) { | ||
max = 1; | ||
} | ||
this.random_number = function(min = 0, max = 1) { | ||
@@ -194,9 +166,3 @@ /* Return a random number between min (inclusive) and max (exclusive). | ||
this.integer_from_normal_float = function(x, min, max) { | ||
if (min == null) { | ||
min = 0; | ||
} | ||
if (max == null) { | ||
max = 2; | ||
} | ||
this.integer_from_normal_float = function(x, min = 0, max = 2) { | ||
@@ -207,9 +173,3 @@ /* Given a 'normal' float `x` so that `0 <= x < 1`, return an integer `n` so that `min <= n < min`. */ | ||
this.random_integer = function(min, max) { | ||
if (min == null) { | ||
min = 0; | ||
} | ||
if (max == null) { | ||
max = 2; | ||
} | ||
this.random_integer = function(min = 0, max = 2) { | ||
@@ -223,34 +183,13 @@ /* Return a random integer between min (inclusive) and max (inclusive). | ||
this.get_rnd_int = function(seed, delta) { | ||
var rnd; | ||
if (seed == null) { | ||
seed = 1; | ||
} | ||
if (delta == null) { | ||
delta = 1; | ||
} | ||
this.get_rnd_int = function(seed = 1, delta = 1) { | ||
/* Like `get_rnd`, but returns a predictable random integer generator. */ | ||
var rnd; | ||
rnd = this.get_rnd(seed, delta); | ||
return (function(_this) { | ||
return function(min, max) { | ||
if (min == null) { | ||
min = 0; | ||
} | ||
if (max == null) { | ||
max = 1; | ||
} | ||
return _this.integer_from_normal_float(rnd(), min, max); | ||
}; | ||
})(this); | ||
return (min = 0, max = 1) => { | ||
return this.integer_from_normal_float(rnd(), min, max); | ||
}; | ||
}; | ||
this.get_rnd = function(seed, delta) { | ||
var R; | ||
if (seed == null) { | ||
seed = 1; | ||
} | ||
if (delta == null) { | ||
delta = 1; | ||
} | ||
this.get_rnd = function(seed = 1, delta = 1) { | ||
@@ -275,2 +214,3 @@ /* This method returns a simple deterministic pseudo-random number generator—basically like | ||
*/ | ||
var R; | ||
R = function() { | ||
@@ -317,3 +257,3 @@ var x; | ||
if (!((Object.prototype.toString.call(x)) === '[object Number]' && isFinite(x))) { | ||
throw "expected a number, got " + ((require('util')).inspect(x)); | ||
throw `expected a number, got ${(require('util')).inspect(x)}`; | ||
} | ||
@@ -350,9 +290,6 @@ }; | ||
this.get_V8_CallSite_objects = function(error) { | ||
var R, prepareStackTrace_original; | ||
if (error == null) { | ||
error = null; | ||
} | ||
this.get_V8_CallSite_objects = function(error = null) { | ||
/* Save original Error.prepareStackTrace */ | ||
var R, prepareStackTrace_original; | ||
prepareStackTrace_original = Error.prepareStackTrace; | ||
@@ -372,16 +309,3 @@ Error.prepareStackTrace = function(ignored, stack) { | ||
this.get_caller_info_stack = function(delta, error, limit, include_source) { | ||
var R, call_sites, cs, entry, i, idx, len; | ||
if (delta == null) { | ||
delta = 0; | ||
} | ||
if (error == null) { | ||
error = null; | ||
} | ||
if (limit == null) { | ||
limit = 2e308; | ||
} | ||
if (include_source == null) { | ||
include_source = false; | ||
} | ||
this.get_caller_info_stack = function(delta = 0, error = null, limit = 2e308, include_source = false) { | ||
@@ -415,2 +339,3 @@ /* Return a list of PODs representing information about the call stack; newest items will be closer | ||
*/ | ||
var R, call_sites, cs, entry, i, idx, len; | ||
if (error == null) { | ||
@@ -444,13 +369,4 @@ delta += +2; | ||
this.get_caller_info = function(delta, error, include_source) { | ||
this.get_caller_info = function(delta = 0, error = null, include_source = false) { | ||
var R; | ||
if (delta == null) { | ||
delta = 0; | ||
} | ||
if (error == null) { | ||
error = null; | ||
} | ||
if (include_source == null) { | ||
include_source = false; | ||
} | ||
R = null; | ||
@@ -575,8 +491,6 @@ while (delta >= 0 && (R == null)) { | ||
var R; | ||
R = (function(_this) { | ||
return function(values, length) { | ||
values.push(R.rnd()); | ||
return _this.create_id(values, length); | ||
}; | ||
})(this); | ||
R = (values, length) => { | ||
values.push(R.rnd()); | ||
return this.create_id(values, length); | ||
}; | ||
R.rnd = this.get_rnd(seed, delta); | ||
@@ -620,7 +534,3 @@ return R; | ||
this.get_app_home = function(routes) { | ||
var error, i, len, route; | ||
if (routes == null) { | ||
routes = null; | ||
} | ||
this.get_app_home = function(routes = null) { | ||
@@ -640,2 +550,3 @@ /* Return the file system route to the current (likely) application folder. This works by traversing all | ||
*/ | ||
var error, i, len, route; | ||
njs_fs = require('fs'); | ||
@@ -661,3 +572,3 @@ if (routes == null) { | ||
} | ||
throw new Error("unable to determine application home; tested routes: \n\n " + (routes.join('\n ')) + "\n"); | ||
throw new Error(`unable to determine application home; tested routes: \n\n ${routes.join('\n ')}\n`); | ||
}; | ||
@@ -698,3 +609,3 @@ | ||
default: | ||
throw new Error("unknown counting selector " + (rpr(selector))); | ||
throw new Error(`unknown counting selector ${rpr(selector)}`); | ||
} | ||
@@ -709,3 +620,3 @@ break; | ||
} | ||
throw new Error("unable to get size of a " + type); | ||
throw new Error(`unable to get size of a ${type}`); | ||
}; | ||
@@ -736,7 +647,7 @@ | ||
*/ | ||
var done, element, i, iterator, len, ref, type_of_sub, type_of_super, value; | ||
var done, element, i, iterator, len, type_of_sub, type_of_super, value; | ||
type_of_sub = CND.type_of(subset); | ||
type_of_super = CND.type_of(superset); | ||
if (type_of_sub !== type_of_super) { | ||
throw new Error("expected two arguments of same type, got " + type_of_sub + " and " + type_of_super); | ||
throw new Error(`expected two arguments of same type, got ${type_of_sub} and ${type_of_super}`); | ||
} | ||
@@ -761,3 +672,3 @@ switch (type_of_sub) { | ||
while (true) { | ||
ref = iterator.next(), value = ref.value, done = ref.done; | ||
({value, done} = iterator.next()); | ||
if (done) { | ||
@@ -772,3 +683,3 @@ return true; | ||
default: | ||
throw new Error("expected lists or sets, got " + type_of_sub + " and " + type_of_super); | ||
throw new Error(`expected lists or sets, got ${type_of_sub} and ${type_of_super}`); | ||
} | ||
@@ -778,10 +689,3 @@ return null; | ||
this.run = function(method, on_error, on_after_error) { | ||
var trycatch, trycatch_settings; | ||
if (on_error == null) { | ||
on_error = null; | ||
} | ||
if (on_after_error == null) { | ||
on_after_error = null; | ||
} | ||
this.run = function(method, on_error = null, on_after_error = null) { | ||
@@ -814,2 +718,3 @@ /* Provide asynchronous error handling and long stacktraces. Usage: | ||
*/ | ||
var trycatch, trycatch_settings; | ||
if (on_error == null) { | ||
@@ -816,0 +721,0 @@ on_error = function(error) { |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.12.4 | ||
// Generated by CoffeeScript 2.0.0-beta3 | ||
@@ -8,6 +8,3 @@ /* LIST methods */ | ||
insert = function(list, item, idx) { | ||
if (idx == null) { | ||
idx = 0; | ||
} | ||
insert = function(list, item, idx = 0) { | ||
list.splice(idx, 0, item); | ||
@@ -17,7 +14,4 @@ return list; | ||
rotate_left = function(list, count) { | ||
rotate_left = function(list, count = 1) { | ||
var _, i, ref; | ||
if (count == null) { | ||
count = 1; | ||
} | ||
if (list.length === 0) { | ||
@@ -32,7 +26,4 @@ return list; | ||
rotate_right = function(list, count) { | ||
rotate_right = function(list, count = 1) { | ||
var _, i, ref; | ||
if (count == null) { | ||
count = 1; | ||
} | ||
if (list.length === 0) { | ||
@@ -39,0 +30,0 @@ return list; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.12.4 | ||
// Generated by CoffeeScript 2.0.0-beta3 | ||
(function() { | ||
@@ -3,0 +3,0 @@ |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.12.4 | ||
// Generated by CoffeeScript 2.0.0-beta3 | ||
(function() { | ||
@@ -3,0 +3,0 @@ |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.12.4 | ||
// Generated by CoffeeScript 2.0.0-beta3 | ||
(function() { | ||
@@ -9,3 +9,3 @@ var base, i, len, method_count, module, name, njs_util, ref, route, routes, rpr, value, σ_cnd; | ||
σ_cnd = Symbol["for"]('cnd'); | ||
σ_cnd = Symbol.for('cnd'); | ||
@@ -30,3 +30,3 @@ if (global[σ_cnd] == null) { | ||
if (this[name] != null) { | ||
throw new Error("duplicate name " + (rpr(name))); | ||
throw new Error(`duplicate name ${rpr(name)}`); | ||
} | ||
@@ -43,4 +43,6 @@ method_count += +1; | ||
this.suspend = require('./suspend'); | ||
}).call(this); | ||
//# sourceMappingURL=main.js.map |
111
lib/tests.js
@@ -1,5 +0,5 @@ | ||
// Generated by CoffeeScript 1.12.4 | ||
// Generated by CoffeeScript 2.0.0-beta3 | ||
(function() { | ||
var CND, TRM, alert, badge, debug, echo, help, include, info, log, njs_path, praise, rpr, test, urge, warn, whisper, | ||
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; | ||
indexOf = [].indexOf; | ||
@@ -12,3 +12,3 @@ njs_path = require('path'); | ||
badge = 'BITSNPIECES/test'; | ||
badge = 'CND/test'; | ||
@@ -187,7 +187,3 @@ log = TRM.get_logger('plain', badge); | ||
}; | ||
d = { | ||
s: s, | ||
m: m, | ||
f: f | ||
}; | ||
d = {s, m, f}; | ||
d_json = CND.XJSON.stringify(d); | ||
@@ -217,5 +213,5 @@ d_ng = CND.XJSON.parse(d_json); | ||
my_local_symbol: Symbol('local-symbol'), | ||
my_global_symbol: Symbol["for"]('global-symbol') | ||
my_global_symbol: Symbol.for('global-symbol') | ||
}; | ||
d[Symbol["for"]('foo')] = 'bar'; | ||
d[Symbol.for('foo')] = 'bar'; | ||
d[Symbol('FOO')] = 'BAR'; | ||
@@ -233,3 +229,3 @@ d_json = CND.XJSON.stringify(d); | ||
d_ng_text = d_ng.my_local_symbol.toString().replace(/^Symbol\((.*)\)$/, '$1'); | ||
T.ok(d.my_local_symbol !== Symbol["for"](d_ng_text)); | ||
T.ok(d.my_local_symbol !== Symbol.for(d_ng_text)); | ||
return null; | ||
@@ -248,2 +244,93 @@ }; | ||
this["suspend (basic)"] = function(T, done) { | ||
var count, step, wait; | ||
({step} = CND.suspend); | ||
count = 0; | ||
wait = function(handler) { | ||
return setTimeout((function() { | ||
return handler(null, 'yes'); | ||
}), 250); | ||
}; | ||
step(function*(resume) { | ||
while (true) { | ||
count += +1; | ||
if (count >= 5) { | ||
break; | ||
} | ||
yield wait(resume); | ||
urge(count); | ||
} | ||
T.eq(count, 5); | ||
help('ok'); | ||
return done(); | ||
}); | ||
return null; | ||
}; | ||
this["suspend (with ordinary function)"] = function(T, done) { | ||
var step; | ||
({step} = CND.suspend); | ||
T.throws('expected a generator function, got a function', (function() { | ||
return step(function(resume) { | ||
return xxx; | ||
}); | ||
})); | ||
done(); | ||
return null; | ||
}; | ||
this["suspend (with custom this)"] = function(T, done) { | ||
var after, count, my_ctx, step; | ||
({step, after} = CND.suspend); | ||
count = 0; | ||
my_ctx = { | ||
foo: 42, | ||
wait: function(dts, handler) { | ||
whisper('before'); | ||
return after(dts, function() { | ||
return handler(null, 'yes'); | ||
}); | ||
} | ||
}; | ||
step(my_ctx, function*(resume) { | ||
while (true) { | ||
count += +1; | ||
whisper((yield this.wait(0.250, resume))); | ||
if (count >= 5) { | ||
break; | ||
} | ||
urge(count); | ||
} | ||
T.eq(count, 5); | ||
help('ok'); | ||
return done(); | ||
}); | ||
return null; | ||
}; | ||
this["isa-generator"] = function(T, done) { | ||
var i, is_gen, is_genf, jr, len, probe, probes_and_matchers, result_is_gen, result_is_genf, type; | ||
probes_and_matchers = [ | ||
[(function() {}), false, false, 'function'], [ | ||
(function*() { | ||
return (yield 42); | ||
}), false, true, 'generatorfunction' | ||
], [ | ||
(function*() { | ||
return (yield 42); | ||
})(), true, false, 'generator' | ||
] | ||
]; | ||
jr = JSON.stringify; | ||
for (i = 0, len = probes_and_matchers.length; i < len; i++) { | ||
[probe, is_gen, is_genf, type] = probes_and_matchers[i]; | ||
result_is_gen = CND.isa_generator(probe); | ||
result_is_genf = CND.isa_generator_function(probe); | ||
T.eq(result_is_gen, is_gen); | ||
T.eq(result_is_genf, is_genf); | ||
T.eq(CND.type_of(probe), type); | ||
} | ||
return done(); | ||
}; | ||
this._main = function(handler) { | ||
@@ -271,3 +358,3 @@ return test(this, { | ||
if (module.parent == null) { | ||
include = ["test type_of", "test size_of", "is_subset", "deep_copy", "XJSON (1)", "XJSON (2)", "XJSON (3)", "logging with timestamps"]; | ||
include = ["suspend (basic)", "suspend (with ordinary function)", "suspend (with custom this)", "isa-generator"]; | ||
this._prune(); | ||
@@ -274,0 +361,0 @@ this._main(); |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.12.4 | ||
// Generated by CoffeeScript 2.0.0-beta3 | ||
(function() { | ||
@@ -3,0 +3,0 @@ this.blink = "\x1b[5m"; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.12.4 | ||
// Generated by CoffeeScript 2.0.0-beta3 | ||
(function() { | ||
@@ -326,3 +326,3 @@ var CND, ansi_vt100_cc_matcher, rgb_hex_by_vt100_colorcode; | ||
} else { | ||
R.push("<span style='color:#" + rgb_hex_by_vt100_colorcode[color_code] + ";'>"); | ||
R.push(`<span style='color:#${rgb_hex_by_vt100_colorcode[color_code]};'>`); | ||
open_span_count += 1; | ||
@@ -351,3 +351,3 @@ } | ||
rgb_hex = rgb_hex_by_vt100_colorcode[color_code]; | ||
R.push("." + css_prefix + "-m-38-5-" + color_code + " { color: " + rgb_hex + "; }"); | ||
R.push(`.${css_prefix}-m-38-5-${color_code} { color: ${rgb_hex}; }`); | ||
} | ||
@@ -354,0 +354,0 @@ return R.join('\n'); |
223
lib/TRM.js
@@ -1,5 +0,4 @@ | ||
// Generated by CoffeeScript 1.12.4 | ||
// Generated by CoffeeScript 2.0.0-beta3 | ||
(function() { | ||
var TYPES, _rpr, badge, color_code, color_name, effect_name, effect_names, effect_off, effect_on, fn, fn1, get_timestamp, isa_text, lines_from_stdout, rainbow_color_names, rainbow_idx, ref, σ_cnd, | ||
slice = [].slice; | ||
var TYPES, _rpr, badge, color_code, color_name, effect_name, effect_names, effect_off, effect_on, fn, fn1, get_timestamp, isa_text, lines_from_stdout, rainbow_color_names, rainbow_idx, ref, σ_cnd; | ||
@@ -22,3 +21,3 @@ this.constants = require('./TRM-CONSTANTS'); | ||
σ_cnd = Symbol["for"]('cnd'); | ||
σ_cnd = Symbol.for('cnd'); | ||
@@ -32,14 +31,8 @@ this.rpr = function(x) { | ||
this.get_output_method = function(target, options) { | ||
return (function(_this) { | ||
return function() { | ||
var P; | ||
P = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
return target.write(_this.pen.apply(_this, P)); | ||
}; | ||
})(this); | ||
return (...P) => { | ||
return target.write(this.pen(...P)); | ||
}; | ||
}; | ||
this.pen = function() { | ||
var P; | ||
P = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
this.pen = function(...P) { | ||
@@ -49,10 +42,9 @@ /* Given any number of arguments, return a text representing the arguments as seen fit for output | ||
*/ | ||
return (this._pen.apply(this, P)).concat('\n'); | ||
return (this._pen(...P)).concat('\n'); | ||
}; | ||
this._pen = function() { | ||
var P, R, p; | ||
P = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
this._pen = function(...P) { | ||
/* ... */ | ||
var R, p; | ||
R = (function() { | ||
@@ -93,17 +85,15 @@ var i, len, results; | ||
R.resume(); | ||
R.on('data', (function(_this) { | ||
return function(key) { | ||
var response; | ||
response = handler(key); | ||
if (key === '\u0003') { | ||
if (last_key_was_ctrl_c) { | ||
process.exit(); | ||
} | ||
last_key_was_ctrl_c = true; | ||
return help("press ctrl-C again to exit"); | ||
} else { | ||
return last_key_was_ctrl_c = false; | ||
R.on('data', (key) => { | ||
var response; | ||
response = handler(key); | ||
if (key === '\u0003') { | ||
if (last_key_was_ctrl_c) { | ||
process.exit(); | ||
} | ||
}; | ||
})(this)); | ||
last_key_was_ctrl_c = true; | ||
return help("press ctrl-C again to exit"); | ||
} else { | ||
return last_key_was_ctrl_c = false; | ||
} | ||
}); | ||
return R; | ||
@@ -157,45 +147,24 @@ }; | ||
this.goto = function(line_nr, column_nr) { | ||
if (line_nr == null) { | ||
line_nr = 1; | ||
} | ||
if (column_nr == null) { | ||
column_nr = 1; | ||
} | ||
return "\x1b[" + line_nr + ";" + column_nr + "H"; | ||
this.goto = function(line_nr = 1, column_nr = 1) { | ||
return `\x1b[${line_nr};${column_nr}H`; | ||
}; | ||
this.goto_column = function(column_nr) { | ||
if (column_nr == null) { | ||
column_nr = 1; | ||
} | ||
return "\x1b[" + column_nr + "G"; | ||
this.goto_column = function(column_nr = 1) { | ||
return `\x1b[${column_nr}G`; | ||
}; | ||
this.up = function(count) { | ||
if (count == null) { | ||
count = 1; | ||
} | ||
return "\x1b[" + count + "A"; | ||
this.up = function(count = 1) { | ||
return `\x1b[${count}A`; | ||
}; | ||
this.down = function(count) { | ||
if (count == null) { | ||
count = 1; | ||
} | ||
return "\x1b[" + count + "B"; | ||
this.down = function(count = 1) { | ||
return `\x1b[${count}B`; | ||
}; | ||
this.right = function(count) { | ||
if (count == null) { | ||
count = 1; | ||
} | ||
return "\x1b[" + count + "C"; | ||
this.right = function(count = 1) { | ||
return `\x1b[${count}C`; | ||
}; | ||
this.left = function(count) { | ||
if (count == null) { | ||
count = 1; | ||
} | ||
return "\x1b[" + count + "D"; | ||
this.left = function(count = 1) { | ||
return `\x1b[${count}D`; | ||
}; | ||
@@ -218,22 +187,19 @@ | ||
fn = (function(_this) { | ||
return function(effect_name, effect_on, effect_off) { | ||
return _this[effect_name] = function() { | ||
var P, R, i, idx, last_idx, len, p; | ||
P = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
R = [effect_on]; | ||
last_idx = P.length - 1; | ||
for (idx = i = 0, len = P.length; i < len; idx = ++i) { | ||
p = P[idx]; | ||
R.push(isa_text(p) ? p : _this.rpr(p)); | ||
if (idx !== last_idx) { | ||
R.push(effect_on); | ||
R.push(_this.separator); | ||
} | ||
fn = (effect_name, effect_on, effect_off) => { | ||
return this[effect_name] = (...P) => { | ||
var R, i, idx, last_idx, len, p; | ||
R = [effect_on]; | ||
last_idx = P.length - 1; | ||
for (idx = i = 0, len = P.length; i < len; idx = ++i) { | ||
p = P[idx]; | ||
R.push(isa_text(p) ? p : this.rpr(p)); | ||
if (idx !== last_idx) { | ||
R.push(effect_on); | ||
R.push(this.separator); | ||
} | ||
R.push(effect_off); | ||
return R.join(''); | ||
}; | ||
} | ||
R.push(effect_off); | ||
return R.join(''); | ||
}; | ||
})(this); | ||
}; | ||
for (effect_name in effect_names) { | ||
@@ -246,22 +212,19 @@ effect_on = this.constants[effect_name]; | ||
ref = this.constants['colors']; | ||
fn1 = (function(_this) { | ||
return function(color_name, color_code) { | ||
return _this[color_name] = function() { | ||
var P, R, i, idx, last_idx, len, p; | ||
P = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
R = [color_code]; | ||
last_idx = P.length - 1; | ||
for (idx = i = 0, len = P.length; i < len; idx = ++i) { | ||
p = P[idx]; | ||
R.push(isa_text(p) ? p : _this.rpr(p)); | ||
if (idx !== last_idx) { | ||
R.push(color_code); | ||
R.push(_this.separator); | ||
} | ||
fn1 = (color_name, color_code) => { | ||
return this[color_name] = (...P) => { | ||
var R, i, idx, last_idx, len, p; | ||
R = [color_code]; | ||
last_idx = P.length - 1; | ||
for (idx = i = 0, len = P.length; i < len; idx = ++i) { | ||
p = P[idx]; | ||
R.push(isa_text(p) ? p : this.rpr(p)); | ||
if (idx !== last_idx) { | ||
R.push(color_code); | ||
R.push(this.separator); | ||
} | ||
R.push(_this.constants['reset']); | ||
return R.join(''); | ||
}; | ||
} | ||
R.push(this.constants['reset']); | ||
return R.join(''); | ||
}; | ||
})(this); | ||
}; | ||
for (color_name in ref) { | ||
@@ -282,18 +245,13 @@ color_code = ref[color_name]; | ||
this.rainbow = function() { | ||
var P; | ||
P = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
this.rainbow = function(...P) { | ||
rainbow_idx = (rainbow_idx + 1) % rainbow_color_names.length; | ||
return this[rainbow_color_names[rainbow_idx]].apply(this, P); | ||
return this[rainbow_color_names[rainbow_idx]](...P); | ||
}; | ||
this.route = function() { | ||
var P; | ||
P = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
return this.lime(this.underline.apply(this, P)); | ||
this.route = function(...P) { | ||
return this.lime(this.underline(...P)); | ||
}; | ||
this.truth = function() { | ||
var P, p; | ||
P = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
this.truth = function(...P) { | ||
var p; | ||
return ((function() { | ||
@@ -304,3 +262,3 @@ var i, len, results; | ||
p = P[i]; | ||
results.push(p ? this.green("✔ " + (this._pen(p))) : this.red("✗ " + (this._pen(p)))); | ||
results.push(p ? this.green(`✔ ${this._pen(p)}`) : this.red(`✗ ${this._pen(p)}`)); | ||
} | ||
@@ -311,7 +269,4 @@ return results; | ||
this.get_logger = function(category, badge) { | ||
this.get_logger = function(category, badge = null) { | ||
var R, colorize, pointer, prefix; | ||
if (badge == null) { | ||
badge = null; | ||
} | ||
switch (category) { | ||
@@ -355,21 +310,13 @@ case 'plain': | ||
default: | ||
throw new Error("unknown logger category " + (_rpr(category))); | ||
throw new Error(`unknown logger category ${_rpr(category)}`); | ||
} | ||
prefix = badge != null ? (this.grey(badge)).concat(' ', pointer) : pointer; | ||
if (colorize != null) { | ||
R = (function(_this) { | ||
return function() { | ||
var P; | ||
P = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
return _this.log((_this.grey(get_timestamp())) + ' ' + prefix, colorize.apply(null, P)); | ||
}; | ||
})(this); | ||
R = (...P) => { | ||
return this.log((this.grey(get_timestamp())) + ' ' + prefix, colorize(...P)); | ||
}; | ||
} else { | ||
R = (function(_this) { | ||
return function() { | ||
var P; | ||
P = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
return _this.log.apply(_this, [(_this.grey(get_timestamp())) + ' ' + prefix].concat(slice.call(P))); | ||
}; | ||
})(this); | ||
R = (...P) => { | ||
return this.log((this.grey(get_timestamp())) + ' ' + prefix, ...P); | ||
}; | ||
} | ||
@@ -392,3 +339,3 @@ return R; | ||
} | ||
return m + ":" + s; | ||
return `${m}:${s}`; | ||
}; | ||
@@ -428,9 +375,7 @@ | ||
this.dir = function() { | ||
var P, arity, i, idx, len, p, r, width, x; | ||
P = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
this.dir = function(...P) { | ||
var arity, i, idx, len, p, r, width, x; | ||
switch (arity = P.length) { | ||
case 0: | ||
throw new Error("called TRM.dir without arguments"); | ||
break; | ||
case 1: | ||
@@ -457,7 +402,7 @@ x = P[0]; | ||
this._dir = function(x) { | ||
var R, i, j, len, len1, marker, name, names, p, ref1, ref2, role, type; | ||
var R, i, j, len, len1, marker, name, names, p, ref1, role, type; | ||
R = []; | ||
ref1 = this._get_prototypes_types_and_property_names(x, []); | ||
for (i = 0, len = ref1.length; i < len; i++) { | ||
ref2 = ref1[i], role = ref2[0], p = ref2[1], type = ref2[2], names = ref2[3]; | ||
[role, p, type, names] = ref1[i]; | ||
R.push(this.grey('('.concat(role, ')'))); | ||
@@ -464,0 +409,0 @@ R.push(this.orange(type)); |
100
lib/TYPES.js
@@ -1,5 +0,4 @@ | ||
// Generated by CoffeeScript 1.12.4 | ||
// Generated by CoffeeScript 2.0.0-beta3 | ||
(function() { | ||
var isBuffer, js_type_of, log, njs_util, ref, rpr, | ||
slice = [].slice; | ||
var js_type_of, log, njs_util, rpr; | ||
@@ -18,7 +17,2 @@ log = console.log; | ||
/* There appear to have been some changes in NodeJS concerning where to find `isXY` methods: */ | ||
isBuffer = (ref = Buffer.isBuffer) != null ? ref : njs_util.isBuffer; | ||
this._coffeenode_type_by_js_type = { | ||
@@ -167,40 +161,21 @@ '[object Array]': 'list', | ||
this.isa_jsbuffer = isBuffer; | ||
if (njs_util.isArray != null) { | ||
this.isa_list = njs_util.isArray; | ||
} | ||
/* https://github.com/blakeembrey/is-generator/blob/master/is-generator.js */ | ||
if (njs_util.isRegExp != null) { | ||
this.isa_jsregex = njs_util.isRegExp; | ||
} | ||
this.isa_generator = function(x) { | ||
return (x != null) && (typeof x.next === 'function') && (typeof x.throw === 'function'); | ||
}; | ||
if (njs_util.isDate != null) { | ||
this.isa_jsdate = njs_util.isDate; | ||
} | ||
this.isa_generator_function = function(x) { | ||
return (typeof x === 'function') && (x.constructor.name === 'GeneratorFunction'); | ||
}; | ||
if (njs_util.isBoolean != null) { | ||
this.isa_boolean = njs_util.isBoolean; | ||
if (Array.isArray != null) { | ||
this.isa_list = Array.isArray; | ||
} | ||
if (njs_util.isError != null) { | ||
this.isa_jserror = njs_util.isError; | ||
if (Buffer.isBuffer != null) { | ||
this.isa_buffer = Buffer.isBuffer; | ||
} | ||
if (njs_util.isFunction != null) { | ||
this.isa_function = njs_util.isFunction; | ||
} | ||
if (njs_util.isPrimitive != null) { | ||
this.isa_primitive = njs_util.isPrimitive; | ||
} | ||
if (njs_util.isString != null) { | ||
this.isa_text = njs_util.isString; | ||
} | ||
if (njs_util.isUndefined != null) { | ||
this.isa_jsundefined = njs_util.isUndefined; | ||
} | ||
this.simple_equality_types = { | ||
@@ -223,5 +198,4 @@ 'number': true, | ||
this.validate_isa = function() { | ||
var i, len, message, probe_type, type, types, x; | ||
x = arguments[0], types = 2 <= arguments.length ? slice.call(arguments, 1) : []; | ||
this.validate_isa = function(x, ...types) { | ||
var i, len, message, probe_type, type; | ||
if (types.length === 0) { | ||
@@ -238,6 +212,6 @@ throw new Error("expected one or more types, got none"); | ||
if (types.length === 1) { | ||
message = "expected a " + types[0] + ", got a " + probe_type; | ||
message = `expected a ${types[0]}, got a ${probe_type}`; | ||
} else { | ||
types = types.join(', '); | ||
message = "expected value to have one of these types: " + types + ", got a " + probe_type; | ||
message = `expected value to have one of these types: ${types}, got a ${probe_type}`; | ||
} | ||
@@ -247,24 +221,22 @@ return null; | ||
(function(_this) { | ||
return (function() { | ||
var match, name, results, type; | ||
results = []; | ||
for (name in _this) { | ||
match = name.match(/^isa_(.+)/); | ||
if (match == null) { | ||
continue; | ||
} | ||
type = match[1]; | ||
results.push((function(name, type) { | ||
return _this["validate_" + name] = function(x) { | ||
if (this[name](x)) { | ||
return null; | ||
} | ||
throw new Error("expected a " + type + ", got a " + (this.type_of(x))); | ||
}; | ||
})(name, type)); | ||
(() => { | ||
var match, name, results, type; | ||
results = []; | ||
for (name in this) { | ||
match = name.match(/^isa_(.+)/); | ||
if (match == null) { | ||
continue; | ||
} | ||
return results; | ||
}); | ||
})(this)(); | ||
type = match[1]; | ||
results.push(((name, type) => { | ||
return this[`validate_${name}`] = function(x) { | ||
if (this[name](x)) { | ||
return null; | ||
} | ||
throw new Error(`expected a ${type}, got a ${this.type_of(x)}`); | ||
}; | ||
})(name, type)); | ||
} | ||
return results; | ||
})(); | ||
@@ -271,0 +243,0 @@ }).call(this); |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.12.4 | ||
// Generated by CoffeeScript 2.0.0-beta3 | ||
@@ -3,0 +3,0 @@ /* |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.12.4 | ||
// Generated by CoffeeScript 2.0.0-beta3 | ||
(function() { | ||
@@ -45,6 +45,6 @@ var CND, log, rpr; | ||
data = value.toString().replace(/^Symbol\((.*)\)$/, '$1'); | ||
local = value === Symbol["for"](data); | ||
local = value === Symbol.for(data); | ||
return { | ||
'~isa': '-x-symbol', | ||
local: local, | ||
local, | ||
'%self': data | ||
@@ -70,3 +70,3 @@ }; | ||
case '-x-symbol': | ||
return Symbol["for"](value['%self']); | ||
return Symbol.for(value['%self']); | ||
} | ||
@@ -73,0 +73,0 @@ return value; |
{ | ||
"name": "cnd", | ||
"version": "4.2.2", | ||
"version": "4.3.0", | ||
"description": "a grab-bag NodeJS package mainly for functionalities that used to live in coffeenode-trm, coffeenode-bitsnpieces, and coffeenode-types", | ||
@@ -5,0 +5,0 @@ "main": "lib/main.js", |
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
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
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
277558
43
2598