Comparing version 4.5.0 to 4.6.0
@@ -1,5 +0,5 @@ | ||
// Generated by CoffeeScript 2.3.1 | ||
// Generated by CoffeeScript 2.4.1 | ||
(function() { | ||
//########################################################################################################### | ||
var CND, njs_fs, njs_path, njs_util, rpr, validate_isa_number, | ||
var CND, PATH, njs_fs, njs_path, njs_util, number_formatter, rpr, validate_isa_number, | ||
indexOf = [].indexOf; | ||
@@ -17,4 +17,8 @@ | ||
this.flatten = require('lodash.flattendeep'); | ||
PATH = require('path'); | ||
this.flatten = function(x, depth = 2e308) { | ||
return x.flat(depth); | ||
}; | ||
//----------------------------------------------------------------------------------------------------------- | ||
@@ -42,2 +46,27 @@ this.equals = function(...P) { | ||
//----------------------------------------------------------------------------------------------------------- | ||
this.here_abspath = function(dirname, ...P) { | ||
return PATH.resolve(dirname, ...P); | ||
}; | ||
this.cwd_abspath = function(...P) { | ||
return PATH.resolve(process.cwd(), ...P); | ||
}; | ||
this.cwd_relpath = function(...P) { | ||
return PATH.relative(process.cwd(), ...P); | ||
}; | ||
//----------------------------------------------------------------------------------------------------------- | ||
this.ensure_directory = function(path) { | ||
return new Promise((resolve, reject) => { | ||
return (require('mkdirp'))(path, (error) => { | ||
if (error != null) { | ||
throw error; | ||
} | ||
return resolve(); | ||
}); | ||
}); | ||
}; | ||
//----------------------------------------------------------------------------------------------------------- | ||
this.copy = function(...P) { | ||
@@ -61,15 +90,6 @@ var type; | ||
//----------------------------------------------------------------------------------------------------------- | ||
this.format_number = function(n, grouper = "'") { | ||
var f, h; | ||
n = n.toString(); | ||
f = function(n) { | ||
return h(n, /(\d+)(\d{3})/); | ||
}; | ||
h = function(n, re) { | ||
while (re.test(n)) { | ||
n = n.replace(re, "$1" + grouper + "$2"); | ||
} | ||
return n; | ||
}; | ||
return f(n); | ||
number_formatter = new Intl.NumberFormat('en-US'); | ||
this.format_number = function(x) { | ||
return number_formatter.format(x); | ||
}; | ||
@@ -76,0 +96,0 @@ |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.3.1 | ||
// Generated by CoffeeScript 2.4.1 | ||
(function() { | ||
@@ -3,0 +3,0 @@ /* LIST methods */ |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.3.1 | ||
// Generated by CoffeeScript 2.4.1 | ||
(function() { | ||
@@ -3,0 +3,0 @@ |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.3.1 | ||
// Generated by CoffeeScript 2.4.1 | ||
(function() { | ||
@@ -3,0 +3,0 @@ |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.3.1 | ||
// Generated by CoffeeScript 2.4.1 | ||
(function() { | ||
@@ -3,0 +3,0 @@ 'use strict'; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.3.1 | ||
// Generated by CoffeeScript 2.4.1 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var CND, suspend, |
@@ -1,7 +0,6 @@ | ||
// Generated by CoffeeScript 2.3.1 | ||
// Generated by CoffeeScript 2.4.1 | ||
(function() { | ||
//########################################################################################################### | ||
// njs_util = require 'util' | ||
var CND, TRM, alert, badge, debug, echo, help, include, info, log, njs_path, praise, rpr, test, urge, warn, whisper, | ||
indexOf = [].indexOf; | ||
var CND, TRM, alert, badge, debug, echo, help, info, log, njs_path, praise, rpr, test, urge, warn, whisper; | ||
@@ -92,3 +91,3 @@ njs_path = require('path'); | ||
T.eq(CND.type_of(12345), 'number'); | ||
T.eq(CND.type_of(new Buffer('helo')), 'buffer'); | ||
T.eq(CND.type_of(Buffer.from('helo')), 'buffer'); | ||
T.eq(CND.type_of(new ArrayBuffer(42)), 'arraybuffer'); | ||
@@ -111,8 +110,8 @@ //......................................................................................................... | ||
this["test size_of"] = function(T) { | ||
// debug ( new Buffer '𣁬', ), ( '𣁬'.codePointAt 0 ).toString 16 | ||
// debug ( new Buffer '𡉜', ), ( '𡉜'.codePointAt 0 ).toString 16 | ||
// debug ( new Buffer '𠑹', ), ( '𠑹'.codePointAt 0 ).toString 16 | ||
// debug ( new Buffer '𠅁', ), ( '𠅁'.codePointAt 0 ).toString 16 | ||
// debug ( Buffer.from '𣁬', ), ( '𣁬'.codePointAt 0 ).toString 16 | ||
// debug ( Buffer.from '𡉜', ), ( '𡉜'.codePointAt 0 ).toString 16 | ||
// debug ( Buffer.from '𠑹', ), ( '𠑹'.codePointAt 0 ).toString 16 | ||
// debug ( Buffer.from '𠅁', ), ( '𠅁'.codePointAt 0 ).toString 16 | ||
T.eq(CND.size_of([1, 2, 3, 4]), 4); | ||
T.eq(CND.size_of(new Buffer([1, 2, 3, 4])), 4); | ||
T.eq(CND.size_of(Buffer.from([1, 2, 3, 4])), 4); | ||
T.eq(CND.size_of('𣁬𡉜𠑹𠅁'), 2 * (Array.from('𣁬𡉜𠑹𠅁')).length); | ||
@@ -127,3 +126,3 @@ T.eq(CND.size_of('𣁬𡉜𠑹𠅁', { | ||
count: 'bytes' | ||
}), (new Buffer('𣁬𡉜𠑹𠅁', 'utf-8')).length); | ||
}), (Buffer.from('𣁬𡉜𠑹𠅁', 'utf-8')).length); | ||
T.eq(CND.size_of('abcdefghijklmnopqrstuvwxyz'), 26); | ||
@@ -409,25 +408,23 @@ T.eq(CND.size_of('abcdefghijklmnopqrstuvwxyz', { | ||
//=========================================================================================================== | ||
// MAIN | ||
//----------------------------------------------------------------------------------------------------------- | ||
this._main = function(handler) { | ||
return test(this, { | ||
'timeout': 2500 | ||
}); | ||
this["path methods"] = function(T, done) { | ||
T.eq(CND.here_abspath('/foo/bar', '/baz/coo'), '/baz/coo'); | ||
T.eq(CND.cwd_abspath('/foo/bar', '/baz/coo'), '/baz/coo'); | ||
T.eq(CND.here_abspath('/baz/coo'), '/baz/coo'); | ||
T.eq(CND.cwd_abspath('/baz/coo'), '/baz/coo'); | ||
T.eq(CND.here_abspath('/foo/bar', 'baz/coo'), '/foo/bar/baz/coo'); | ||
T.eq(CND.cwd_abspath('/foo/bar', 'baz/coo'), '/foo/bar/baz/coo'); | ||
// T.eq ( CND.here_abspath 'baz/coo' ), '/....../cnd/baz/coo' | ||
// T.eq ( CND.cwd_abspath 'baz/coo' ), '/....../cnd/baz/coo' | ||
// T.eq ( CND.here_abspath __dirname, 'baz/coo', 'x.js' ), '/....../cnd/lib/baz/coo/x.js' | ||
return done(); | ||
}; | ||
//----------------------------------------------------------------------------------------------------------- | ||
this._prune = function() { | ||
var name, ref, value; | ||
ref = this; | ||
for (name in ref) { | ||
value = ref[name]; | ||
if (name.startsWith('_')) { | ||
continue; | ||
} | ||
if (indexOf.call(include, name) < 0) { | ||
delete this[name]; | ||
} | ||
} | ||
return null; | ||
this["format_number"] = function(T, done) { | ||
T.eq(CND.format_number(42), '42'); | ||
T.eq(CND.format_number(42000), '42,000'); | ||
T.eq(CND.format_number(42000.1234), '42,000.123'); | ||
T.eq(CND.format_number(42.1234e6), '42,123,400'); | ||
return done(); | ||
}; | ||
@@ -437,9 +434,12 @@ | ||
if (module.parent == null) { | ||
include = ["test type_of", "test size_of", "is_subset", "deep_copy", "XJSON (1)", "XJSON (2)", "XJSON (3)", "logging with timestamps", "suspend (basic)", "suspend (with ordinary function)", "suspend (with custom this)", "isa-generator"]; | ||
this._prune(); | ||
this._main(); | ||
test(this, { | ||
'timeout': 2500 | ||
}); | ||
} | ||
// test @[ "path methods" ] | ||
// test @[ "format_number" ] | ||
}).call(this); | ||
//# sourceMappingURL=tests.js.map |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.3.1 | ||
// Generated by CoffeeScript 2.4.1 | ||
(function() { | ||
@@ -3,0 +3,0 @@ //----------------------------------------------------------------------------------------------------------- |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.3.1 | ||
// Generated by CoffeeScript 2.4.1 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var CND, ansi_vt100_cc_matcher, rgb_hex_by_vt100_colorcode; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.3.1 | ||
// Generated by CoffeeScript 2.4.1 | ||
(function() { | ||
@@ -3,0 +3,0 @@ //########################################################################################################### |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.3.1 | ||
// Generated by CoffeeScript 2.4.1 | ||
(function() { | ||
@@ -3,0 +3,0 @@ //########################################################################################################### |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.3.1 | ||
// Generated by CoffeeScript 2.4.1 | ||
(function() { | ||
@@ -3,0 +3,0 @@ /* |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.3.1 | ||
// Generated by CoffeeScript 2.4.1 | ||
(function() { | ||
@@ -3,0 +3,0 @@ //########################################################################################################### |
{ | ||
"name": "cnd", | ||
"version": "4.5.0", | ||
"version": "4.6.0", | ||
"description": "a grab-bag NodeJS package mainly for functionalities that used to live in coffeenode-trm, coffeenode-bitsnpieces, and coffeenode-types", | ||
@@ -29,8 +29,8 @@ "main": "lib/main.js", | ||
"dependencies": { | ||
"lodash.flattendeep": "^4.4.0", | ||
"mkdirp": "^0.5.1", | ||
"trycatch": "^1.5.21" | ||
}, | ||
"devDependencies": { | ||
"guy-test": "^1.3.1" | ||
"guy-test": "^1.4.0" | ||
} | ||
} |
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
446369
3089
+ Addedmkdirp@^0.5.1
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
- Removedlodash.flattendeep@^4.4.0
- Removedlodash.flattendeep@4.4.0(transitive)