Comparing version 0.1.5 to 0.1.6
@@ -16,3 +16,4 @@ { | ||
"--runInBand", | ||
"--logHeapUsage" | ||
"--logHeapUsage", | ||
"--colors" | ||
], | ||
@@ -37,3 +38,3 @@ "console": "integratedTerminal", | ||
"func2/cache." | ||
"func2/object." | ||
], | ||
@@ -40,0 +41,0 @@ "console": "integratedTerminal", |
@@ -1,2 +0,4 @@ | ||
const v8 = require('v8'); | ||
//const v8 = require('v8'); | ||
const { MessageChannel, receiveMessageOnPort } = require('worker_threads'); | ||
const { port1: clonePort1, port2: clonePort2 } = new MessageChannel(); | ||
const $ = require('../base'); | ||
@@ -207,3 +209,5 @@ | ||
func_(function clone(value) { | ||
return v8.deserialize(v8.serialize(value)); | ||
//return v8.deserialize(v8.serialize(value)); | ||
clonePort1.postMessage(value); | ||
return receiveMessageOnPort(clonePort2).message; | ||
}); | ||
@@ -210,0 +214,0 @@ |
@@ -5,2 +5,6 @@ const $ = require('../base'); | ||
func_(function getClass(obj) { | ||
return Object.getPrototypeOf(obj)?.constructor ?? Object; | ||
}); | ||
func_(function echo(value) { | ||
@@ -45,2 +49,10 @@ return value; | ||
func_(function isNullish(value) { | ||
return value == null; | ||
}); | ||
func_(function isNotNullish(value) { | ||
return value != null; | ||
}); | ||
func_(function not(value) { | ||
@@ -253,2 +265,3 @@ return !value; | ||
$.dbglog = $.debug_(console.log); | ||
$.dbglog_ = (...args) => $.debug_(console.log, ...args); | ||
@@ -314,2 +327,16 @@ func_(function relay_(...funcs) { | ||
const hasProtos = new Set([Map.prototype, WeakMap.prototype, Set.prototype, WeakSet.prototype]); | ||
func_(function has_(where) { | ||
if (where == null) return $.null; | ||
if (hasProtos.has(Object.getPrototypeOf(where))) return value => where.has(value); | ||
return value => value in where; | ||
}); | ||
func_(function hasOwn_(where) { | ||
if (where == null) return $.null; | ||
if (hasProtos.has(Object.getPrototypeOf(where))) return value => where.has(value); | ||
return value => Object.hasOwnProperty.call(where, value); | ||
}); | ||
$.stop = Symbol('$.stop'); | ||
@@ -316,0 +343,0 @@ $.pass = Symbol('$.pass'); |
@@ -31,2 +31,10 @@ const $ = require('./map'); | ||
test('$.isNullish: is null or undefined', () => { | ||
expect([1, undefined, 0, 'a', null, {a: 1}, [5]].map($.isNullish)).toEqual([false, true, false, false, true, false, false]); | ||
}); | ||
test('$.isNotNullish: is not null or undefined', () => { | ||
expect([1, undefined, 0, 'a', null, {a: 1}, [5]].map($.isNotNullish)).toEqual([true, false, true, true, false, true, true]); | ||
}); | ||
test('$.not_: not func result', () => { | ||
@@ -188,1 +196,25 @@ expect([1, '2', false].map($.not_(v => typeof v === 'string'))).toEqual([true, false, true]); | ||
}); | ||
test('$.has_: contained in', () => { | ||
expect($.has_()('a')).toBe(null); | ||
expect($.has_({a: 1, b: 2})('a')).toBe(true); | ||
expect($.has_({a: 1, b: 2})('c')).toBe(false); | ||
expect($.has_({a: 1, b: 2})('constructor')).toBe(true); | ||
expect($.has_([, 2])(0)).toBe(false); | ||
expect($.has_([, 2])(1)).toBe(true); | ||
expect($.has_(new Set(['a', 'b']))('b')).toBe(true); | ||
expect($.has_(new Set(['a', 'b']))('c')).toBe(false); | ||
expect($.has_(new Map([['a', 1], ['b', 2]]))('a')).toBe(true); | ||
}); | ||
test('$.hasOwn_: contained in', () => { | ||
expect($.hasOwn_()('a')).toBe(null); | ||
expect($.hasOwn_({a: 1, b: 2})('a')).toBe(true); | ||
expect($.hasOwn_({a: 1, b: 2})('c')).toBe(false); | ||
expect($.hasOwn_({a: 1, b: 2})('constructor')).toBe(false); | ||
expect($.hasOwn_([, 2])(0)).toBe(false); | ||
expect($.hasOwn_([, 2])(1)).toBe(true); | ||
expect($.hasOwn_(new Set(['a', 'b']))('b')).toBe(true); | ||
expect($.hasOwn_(new Set(['a', 'b']))('c')).toBe(false); | ||
expect($.hasOwn_(new Map([['a', 1], ['b', 2]]))('a')).toBe(true); | ||
}); |
@@ -30,3 +30,3 @@ const $ = require('./cache'); | ||
const isNotUsed = (step) => !used.has(step); | ||
const isNotUsed = ([step]) => !used.has(step); | ||
const maxDist = (a, b) => b.dist - a.dist; | ||
@@ -38,6 +38,6 @@ | ||
while ((arg.cur = walk.pop()) && isNotUsed(arg.cur.step)) { | ||
while ((arg.cur = walk.pop()) && !used.has(arg.cur.step)) { | ||
const node = this.tadj.get(arg.cur.step); | ||
if (!node) continue; | ||
new Iter(node).filter('0', isNotUsed).call(lessDist).exec(); | ||
new Iter(node).filter(isNotUsed).call(lessDist).exec(); | ||
used.add(arg.cur.step); | ||
@@ -44,0 +44,0 @@ } |
@@ -141,1 +141,17 @@ const $ = require('./graph'); | ||
}); | ||
test('Graph: wikipedia', () => { | ||
const gr = new $.Graph(); | ||
gr.link2(4, 5, 6); | ||
gr.link2(6, 5, 9); | ||
gr.link2(3, 6, 2); | ||
gr.link2(3, 4, 11); | ||
gr.link2(2, 4, 15); | ||
gr.link2(2, 3, 10); | ||
gr.link2(1, 6, 14); | ||
gr.link2(1, 3, 9); | ||
gr.link2(1, 2, 7); | ||
expect(Array.from(gr.pathOn(1, 5))).toEqual([1, 3, 6, 5]); | ||
expect(gr.shortestDist(1, 5)).toBe(20); | ||
expect(gr.shortestSteps(1, 5)).toBe(3); | ||
}); |
const $ = require('../func'); | ||
require('./object'); | ||
require('./acc'); | ||
@@ -4,0 +5,0 @@ require('./promise'); |
@@ -73,7 +73,7 @@ const Iter = require('./filter'); | ||
const origLog = console.log; | ||
console.log = (...ents) => logs.push(...ents); | ||
console.log = (...ents) => logs.push(ents); | ||
try { | ||
const wr = new Iter(['test']); | ||
wr.dbglog('Iter.dbglog'); | ||
wr.dbglog('Iter.dbglog').debug($.dbglog_('$.dbglog_')); | ||
res = Array.from(wr); | ||
@@ -85,3 +85,3 @@ } finally { | ||
expect(res).toEqual(['test']); | ||
expect(logs).toEqual(['Iter.dbglog', 'test']); | ||
expect(logs).toEqual([['Iter.dbglog', 'test'], ['$.dbglog_', 'test']]); | ||
}); | ||
@@ -88,0 +88,0 @@ |
@@ -23,3 +23,11 @@ /* | ||
// An array of glob patterns indicating a set of files for which coverage information should be collected | ||
//collectCoverageFrom: [], | ||
// collectCoverageFrom: [ | ||
// 'algo/**/*.js', | ||
// 'as-it/**/*.js', | ||
// 'func/**/*.js', | ||
// 'func2/**/*.js', | ||
// 'iter/**/*.js', | ||
// 'base.js', | ||
// 'index.js', | ||
// ], | ||
@@ -159,2 +167,3 @@ // The directory where Jest should output its coverage files | ||
"<rootDir>/\.local/", | ||
"<rootDir>/\.vscode/", | ||
], | ||
@@ -161,0 +170,0 @@ |
{ | ||
"name": "asclasit", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "ASync CLasses + ASync ITerators", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
344004
83
9907
0