Comparing version 1.0.36 to 1.0.37
{ | ||
"name": "js-awe", | ||
"version": "1.0.36", | ||
"version": "1.0.37", | ||
"homepage": "https://github.com/josuamanuel/js-awe", | ||
@@ -19,3 +19,4 @@ "author": "josuamanuel@hotmail.com", | ||
"timeline", | ||
"utils" | ||
"utils", | ||
"console.table" | ||
], | ||
@@ -27,9 +28,15 @@ "type": "module", | ||
"test": "npm run testUT", | ||
"testUT": "export CONFIG_ENV=Testing && export LOG_LEVEL=SILENT && mocha ./test/**/*.js" | ||
"testUT": "export CONFIG_ENV=Testing && export LOG_LEVEL=SILENT && mocha ./test/**/*.js", | ||
"build": "rollup -c" | ||
}, | ||
"license": "MIT", | ||
"devDependencies": { | ||
"mocha": "^10.0.0" | ||
"@rollup/plugin-node-resolve": "^15.1.0", | ||
"@rollup/plugin-terser": "^0.4.3", | ||
"@rollup/plugin-typescript": "^11.1.2", | ||
"rollup": "^3.26.2", | ||
"rollup-plugin-node-polyfills": "^0.2.1" | ||
}, | ||
"dependencies": { | ||
"@rollup/plugin-commonjs": "^25.0.2", | ||
"@types/node": "^18.6.1", | ||
@@ -42,5 +49,5 @@ "fluture": "^14.0.0", | ||
"loglevel": "^1.8.0", | ||
"node-fetch": "^3.2.10", | ||
"mocha": "^10.2.0", | ||
"ramda": "^0.28.0" | ||
} | ||
} |
@@ -21,4 +21,21 @@ # js-awe | ||
A minified version soon to come... | ||
Grab the minified version at: | ||
<https://raw.githubusercontent.com/josuamanuel/js-awe/main/dist/js-awe.min.js> | ||
Then copy it in your project and work with it in your html: | ||
```html | ||
... | ||
<body> | ||
<script type="module"> | ||
import { firstCapital} from './js-awe.min.js' | ||
document.write(firstCapital("library is loaded correctly...")); | ||
</script> | ||
</body> | ||
... | ||
``` | ||
## New functional async style. Avoid await contamination | ||
@@ -184,6 +201,4 @@ | ||
[chronoExample.js](https://github.com/josuamanuel/js-awe/blob/main/sandbox/Chrono/chronoExample.js) | ||
Spread in your Async code some: | ||
Spread around your async code some: | ||
```Javascript | ||
@@ -196,2 +211,4 @@ chrono.time('step1') | ||
Full example: [chronoExample.js](https://github.com/josuamanuel/js-awe/blob/main/sandbox/Chrono/chronoExample.js) | ||
```Plaintext | ||
@@ -198,0 +215,0 @@ chronoCreation : 2023-05-25T20:58:17.175Z |
@@ -7,4 +7,17 @@ import { arraySorter, pushUniqueKeyOrChange, sorterByPaths, pushUniqueKey, CustomError, pushAt } from './jsUtils.js'; | ||
import { Timeline } from './table/components/timeline.js' | ||
import { performance } from 'node:perf_hooks' | ||
let myGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : typeof this !== 'undefined' ? this : {}; | ||
let performance = myGlobal?.performance | ||
if(performance === undefined) { | ||
try { | ||
performance = (await import('perf_hooks')).performance | ||
}catch(e){} | ||
} | ||
if(performance === undefined) performance = {} | ||
// needed only for debuging | ||
@@ -324,3 +337,9 @@ //import { RE } from './ramdaExt.js'; | ||
function timelineReport(data) { | ||
function logTimeline(timeline) { | ||
console.log('') | ||
console.log('Timeline of events:') | ||
console.log(timeline.draw()) | ||
} | ||
function createTimeline(data) { | ||
const timeline = Table(data) | ||
@@ -331,7 +350,3 @@ | ||
console.log('') | ||
console.log('Timeline of events:') | ||
console.log(timeline.draw()) | ||
return data | ||
return timeline | ||
} | ||
@@ -348,3 +363,4 @@ | ||
})) | ||
timelineReport(toReport) | ||
const toLog = createTimeline(toReport) | ||
logTimeline(toLog) | ||
@@ -354,2 +370,14 @@ return data | ||
function timelineLines() { | ||
let toReport = Object.entries(historyTimeIntervals).map( | ||
([eventName, event]) => ( | ||
{ | ||
event: eventName, | ||
ranges: event.ranges.map( | ||
({ start, end }) => ({ start: Math.floor(start), end: Math.floor(end) }) | ||
) | ||
})) | ||
return createTimeline(toReport).draw() | ||
} | ||
function chronoReport() { | ||
@@ -534,3 +562,3 @@ console.log('') | ||
return { | ||
time, timeEnd, report, setTime, setTimeEnd, logReport, | ||
time, timeEnd, report, setTime, setTimeEnd, logReport, timelineLines, | ||
getChronoState, setChronoStateUsingPerformanceAPIFormat, getChronoStateUsingPerformanceAPIFormat, average, | ||
@@ -537,0 +565,0 @@ reset |
@@ -1,2 +0,1 @@ | ||
import fetch from 'node-fetch' | ||
@@ -10,2 +9,2 @@ async function fetchImproved(...args) { | ||
export { fetch, fetchImproved } | ||
export { fetchImproved } |
@@ -526,3 +526,4 @@ 'use strict' | ||
function project(paths, json) { | ||
function project(paths, json, removeWithDelete=true) { | ||
const toDelete = Symbol() | ||
let copy | ||
@@ -545,9 +546,34 @@ if (json === null || json === undefined ) return json | ||
result.map((el) => el.path) // ? | ||
result.forEach(({ pointer, value }) => { | ||
let pendingToFilter= new Map() | ||
result.forEach(({ pointer, value }, index) => { | ||
const setAtPath = pointer.substring(1).split('/') | ||
if (setAtPath.length === 1 && setAtPath[0] === '') copy = isInclude ? value : undefined | ||
else setAt(copy, setAtPath, isInclude ? value : undefined) | ||
if (setAtPath.length === 1 && setAtPath[0] === '') copy = isInclude ? clone(value) : undefined | ||
else { | ||
if(removeWithDelete === true && isInclude === false) { | ||
const parentPath = setAtPath.slice(0,-1) | ||
const parent = getAt(copy, parentPath) | ||
if(Array.isArray(parent) === true) { | ||
// Arrays are stored in a map to be reviewed later to filter out the items mark for deletion. | ||
pendingToFilter.set(parentPath.join('/'), parent) | ||
// mark element for deletion | ||
setAt(copy, setAtPath, toDelete) | ||
}else { | ||
const fieldToDelete = setAtPath[setAtPath.length -1] | ||
delete parent[fieldToDelete] | ||
setAt(copy, parentPath, parent) | ||
} | ||
}else | ||
setAt(copy, setAtPath, isInclude ? clone(value) : undefined) | ||
} | ||
}) | ||
pendingToFilter.forEach((parent, parentPath) => { | ||
const compactingDeleteItems = parent.filter(el => el !== toDelete) | ||
setAt(copy, parentPath.split('/'), compactingDeleteItems) | ||
}) | ||
}) | ||
@@ -557,31 +583,33 @@ | ||
} | ||
//{ | ||
// const users = [ | ||
// { | ||
// name: 'Jose', | ||
// age: 47, | ||
// salary: 52000, | ||
// posts: [ | ||
// { id: 1, message: 'test', likes: 2 }, | ||
// { id: 2, message: 'test1', likes: 2 }, | ||
// { id: 3, message: 'test2', likes: 2 }, | ||
// ], | ||
// }, | ||
// { | ||
// name: 'Luchi', | ||
// age: 49, | ||
// salary: 52000, | ||
// posts: [ | ||
// { id: 1, message: 'testL', likes: 2 }, | ||
// { id: 2, message: 'testL1', likes: 2 }, | ||
// { id: 3, message: 'testL2', likes: 2 }, | ||
// ], | ||
// }, | ||
// ] | ||
// { | ||
// const users = [ | ||
// { | ||
// name: 'Jose', | ||
// age: 47, | ||
// salary: 52000, | ||
// posts: [ | ||
// { id: 1, message: 'test', likes: 2 }, | ||
// { id: 2, message: 'test1', likes: 2 }, | ||
// { id: 3, message: 'test2', likes: 2 }, | ||
// ], | ||
// }, | ||
// { | ||
// name: 'Luchi', | ||
// age: 49, | ||
// salary: 52000, | ||
// twoLevels: {a:3}, | ||
// posts: [ | ||
// { id: 1, message: 'testL', likes: 2 }, | ||
// { id: 2, message: 'testL1', likes: 2 }, | ||
// { id: 3, message: 'testL2', likes: 2 }, | ||
// ], | ||
// }, | ||
// ] | ||
// const pathToSelect = ['+$', '-$[*].age', '-$[*].salary', '-$[*].posts[:-1]'] //, '-$[*].age']; | ||
// const pathToSelect = ['+$', '-$[*].age', '-$[*].twoLevels.a', '-$[*].posts[:-1]'] //, '-$[*].age']; | ||
// project(pathToSelect, users) // ? | ||
// project(['+$'], 2) //? | ||
//} | ||
// project(pathToSelect, users) | ||
// project(['+$[*].posts[0,2]', '-$[*].posts[1]'], users) | ||
// project(['+$'], 2) //? | ||
// } | ||
@@ -588,0 +616,0 @@ |
@@ -168,4 +168,7 @@ import { Text } from './components/text.js' | ||
{ | ||
let myGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : typeof this !== 'undefined' ? this : {}; | ||
if (console.table) { | ||
if(globalThis?.process?.argv0 === 'bun') console.log(Table(toLog).auto().draw()) | ||
if(myGlobal?.process?.argv0 === 'bun') console.log(Table(toLog).auto().draw()) | ||
else console.table(toLog) | ||
@@ -172,0 +175,0 @@ }else console.log(toLog) |
@@ -1,2 +0,2 @@ | ||
import fetch from "node-fetch"; | ||
declare function fetchImproved(...args: any[]): Promise<{ | ||
@@ -3,0 +3,0 @@ status: number; |
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
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
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
789981
70
24476
266
10
5
4
+ Addedmocha@^10.2.0
+ Added@jridgewell/sourcemap-codec@1.5.0(transitive)
+ Added@rollup/plugin-commonjs@25.0.8(transitive)
+ Added@rollup/pluginutils@5.1.2(transitive)
+ Added@types/estree@1.0.6(transitive)
+ Addedansi-colors@4.1.3(transitive)
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedanymatch@3.1.3(transitive)
+ Addedargparse@2.0.1(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbinary-extensions@2.3.0(transitive)
+ Addedbrace-expansion@2.0.1(transitive)
+ Addedbraces@3.0.3(transitive)
+ Addedbrowser-stdout@1.3.1(transitive)
+ Addedcamelcase@6.3.0(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedchokidar@3.6.0(transitive)
+ Addedcliui@7.0.4(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcommondir@1.0.1(transitive)
+ Addeddebug@4.3.7(transitive)
+ Addeddecamelize@4.0.0(transitive)
+ Addeddiff@5.2.0(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedescape-string-regexp@4.0.0(transitive)
+ Addedestree-walker@2.0.2(transitive)
+ Addedfill-range@7.1.1(transitive)
+ Addedfind-up@5.0.0(transitive)
+ Addedflat@5.0.2(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedfsevents@2.3.3(transitive)
+ Addedget-caller-file@2.0.5(transitive)
+ Addedglob@8.1.0(transitive)
+ Addedglob-parent@5.1.2(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedhe@1.2.0(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-binary-path@2.1.0(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedis-glob@4.0.3(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addedis-plain-obj@2.1.0(transitive)
+ Addedis-reference@1.2.1(transitive)
+ Addedis-unicode-supported@0.1.0(transitive)
+ Addedjs-yaml@4.1.0(transitive)
+ Addedlocate-path@6.0.0(transitive)
+ Addedlog-symbols@4.1.0(transitive)
+ Addedmagic-string@0.30.11(transitive)
+ Addedminimatch@5.1.6(transitive)
+ Addedmocha@10.7.3(transitive)
+ Addedms@2.1.3(transitive)
+ Addednormalize-path@3.0.0(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedp-limit@3.1.0(transitive)
+ Addedp-locate@5.0.0(transitive)
+ Addedpath-exists@4.0.0(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedrandombytes@2.1.0(transitive)
+ Addedreaddirp@3.6.0(transitive)
+ Addedrequire-directory@2.1.1(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedserialize-javascript@6.0.2(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedstrip-json-comments@3.1.1(transitive)
+ Addedsupports-color@7.2.08.1.1(transitive)
+ Addedto-regex-range@5.0.1(transitive)
+ Addedworkerpool@6.5.1(transitive)
+ Addedwrap-ansi@7.0.0(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedy18n@5.0.8(transitive)
+ Addedyargs@16.2.0(transitive)
+ Addedyargs-parser@20.2.9(transitive)
+ Addedyargs-unparser@2.0.0(transitive)
+ Addedyocto-queue@0.1.0(transitive)
- Removednode-fetch@^3.2.10
- Removeddata-uri-to-buffer@4.0.1(transitive)
- Removedfetch-blob@3.2.0(transitive)
- Removedformdata-polyfill@4.0.10(transitive)
- Removednode-domexception@1.0.0(transitive)
- Removednode-fetch@3.3.2(transitive)
- Removedweb-streams-polyfill@3.3.3(transitive)