@koine/node 2.0.0-beta.132 → 2.0.0-beta.134

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/fsWrite.cjs.js CHANGED
@@ -6,39 +6,7 @@ var promises = require('node:fs/promises');
6
6
  var node_os = require('node:os');
7
7
  var node_path = require('node:path');
8
8
 
9
- // * Returns the index of the last element in the array where predicate is true, and -1
10
- // * otherwise.
11
- // *
12
- // * @borrows [SO's answer by Nico Timmerman](https://stackoverflow.com/a/53187807/1938970)
13
- // *
14
- // * @param array The source array to search in
15
- // * @param predicate find calls predicate once for each element of the array, in descending
16
- // * order, until it finds one where predicate returns true. If such an element is found,
17
- // * findLastIndex immediately returns that element index. Otherwise, findLastIndex returns -1.
18
- // */
19
- // let findLastIndex = <T>(array: Array<T>, predicate: (value: T, index: number, obj: T[]) => boolean): number => {
20
- // let l = array.length;
21
- // while (l--) {
22
- // if (predicate(array[l], l, array))
23
- // return l;
24
- // }
25
- // return -1;
26
- // }
27
- /**
28
- * Write file
29
- *
30
- * @param filepath The absolute file path
31
- * @param content The file content string
32
- * @param eol By default we apend a `node:os.EOL` end of line a the end of the file
33
- */async function fsWrite(a,f,s=!0){await promises.mkdir(node_path.dirname(a),{recursive:!0}),// remove empty first line
34
- f=f.replace(/^\s*/m,""),await promises.writeFile(a,f),s&&// multiline trim: removes empty lines at begininng and end of a multiline string
35
- // const lines = content.split("\n");
36
- // content = lines
37
- // // .slice(lines.findIndex(Boolean), lines.findLastIndex(Boolean) - 1)
38
- // .slice(lines.findIndex(Boolean), findLastIndex(lines, Boolean) - 1)
39
- // .join("\n");
40
- // @see https://stackoverflow.com/a/72653325/1938970
41
- await promises.appendFile(a,node_os.EOL,"utf8");}// await appendFile(filepath, EOL, "utf8");
9
+ async function fsWrite(a,f,s=!0){await promises.mkdir(node_path.dirname(a),{recursive:!0}),f=f.replace(/^\s*/m,""),await promises.writeFile(a,f),s&&await promises.appendFile(a,node_os.EOL,"utf8");}
42
10
 
43
11
  exports.default = fsWrite;
44
12
  exports.fsWrite = fsWrite;
package/fsWrite.d.ts CHANGED
@@ -1,2 +1,9 @@
1
+ /**
2
+ * Write file
3
+ *
4
+ * @param filepath The absolute file path
5
+ * @param content The file content string
6
+ * @param eol By default we apend a `node:os.EOL` end of line a the end of the file
7
+ */
1
8
  export declare function fsWrite(filepath: string, content: string, eol?: boolean): Promise<void>;
2
9
  export default fsWrite;
package/fsWrite.esm.js CHANGED
@@ -2,38 +2,6 @@ import { mkdir, writeFile, appendFile } from 'node:fs/promises';
2
2
  import { EOL } from 'node:os';
3
3
  import { dirname } from 'node:path';
4
4
 
5
- // * Returns the index of the last element in the array where predicate is true, and -1
6
- // * otherwise.
7
- // *
8
- // * @borrows [SO's answer by Nico Timmerman](https://stackoverflow.com/a/53187807/1938970)
9
- // *
10
- // * @param array The source array to search in
11
- // * @param predicate find calls predicate once for each element of the array, in descending
12
- // * order, until it finds one where predicate returns true. If such an element is found,
13
- // * findLastIndex immediately returns that element index. Otherwise, findLastIndex returns -1.
14
- // */
15
- // let findLastIndex = <T>(array: Array<T>, predicate: (value: T, index: number, obj: T[]) => boolean): number => {
16
- // let l = array.length;
17
- // while (l--) {
18
- // if (predicate(array[l], l, array))
19
- // return l;
20
- // }
21
- // return -1;
22
- // }
23
- /**
24
- * Write file
25
- *
26
- * @param filepath The absolute file path
27
- * @param content The file content string
28
- * @param eol By default we apend a `node:os.EOL` end of line a the end of the file
29
- */async function fsWrite(a,f,s=!0){await mkdir(dirname(a),{recursive:!0}),// remove empty first line
30
- f=f.replace(/^\s*/m,""),await writeFile(a,f),s&&// multiline trim: removes empty lines at begininng and end of a multiline string
31
- // const lines = content.split("\n");
32
- // content = lines
33
- // // .slice(lines.findIndex(Boolean), lines.findLastIndex(Boolean) - 1)
34
- // .slice(lines.findIndex(Boolean), findLastIndex(lines, Boolean) - 1)
35
- // .join("\n");
36
- // @see https://stackoverflow.com/a/72653325/1938970
37
- await appendFile(a,EOL,"utf8");}// await appendFile(filepath, EOL, "utf8");
5
+ async function fsWrite(a,f,s=!0){await mkdir(dirname(a),{recursive:!0}),f=f.replace(/^\s*/m,""),await writeFile(a,f),s&&await appendFile(a,EOL,"utf8");}
38
6
 
39
7
  export { fsWrite as default, fsWrite };
@@ -6,21 +6,7 @@ var node_fs = require('node:fs');
6
6
  var node_os = require('node:os');
7
7
  var node_path = require('node:path');
8
8
 
9
- /**
10
- * Write file
11
- *
12
- * @param filepath The absolute file path
13
- * @param content The file content string
14
- * @param eol By default we apend a `node:os.EOL` end of line a the end of the file
15
- */function fsWriteSync(i,m,n=!0){node_fs.mkdirSync(node_path.dirname(i),{recursive:!0}),node_fs.writeFileSync(i,// remove empty first line
16
- m=m.replace(/^\s*/m,"")),n&&// multiline trim: removes empty lines at begininng and end of a multiline string
17
- // const lines = content.split("\n");
18
- // content = lines
19
- // // .slice(lines.findIndex(Boolean), lines.findLastIndex(Boolean) - 1)
20
- // .slice(lines.findIndex(Boolean), findLastIndex(lines, Boolean) - 1)
21
- // .join("\n");
22
- // @see https://stackoverflow.com/a/72653325/1938970
23
- node_fs.appendFileSync(i,node_os.EOL,"utf8");}// appendFileSync(filepath, EOL, "utf8");
9
+ function fsWriteSync(i,m,n=!0){node_fs.mkdirSync(node_path.dirname(i),{recursive:!0}),node_fs.writeFileSync(i,m=m.replace(/^\s*/m,"")),n&&node_fs.appendFileSync(i,node_os.EOL,"utf8");}
24
10
 
25
11
  exports.default = fsWriteSync;
26
12
  exports.fsWriteSync = fsWriteSync;
package/fsWriteSync.d.ts CHANGED
@@ -1,2 +1,9 @@
1
+ /**
2
+ * Write file
3
+ *
4
+ * @param filepath The absolute file path
5
+ * @param content The file content string
6
+ * @param eol By default we apend a `node:os.EOL` end of line a the end of the file
7
+ */
1
8
  export declare function fsWriteSync(filepath: string, content: string, eol?: boolean): void;
2
9
  export default fsWriteSync;
@@ -2,20 +2,6 @@ import { mkdirSync, writeFileSync, appendFileSync } from 'node:fs';
2
2
  import { EOL } from 'node:os';
3
3
  import { dirname } from 'node:path';
4
4
 
5
- /**
6
- * Write file
7
- *
8
- * @param filepath The absolute file path
9
- * @param content The file content string
10
- * @param eol By default we apend a `node:os.EOL` end of line a the end of the file
11
- */function fsWriteSync(i,m,n=!0){mkdirSync(dirname(i),{recursive:!0}),writeFileSync(i,// remove empty first line
12
- m=m.replace(/^\s*/m,"")),n&&// multiline trim: removes empty lines at begininng and end of a multiline string
13
- // const lines = content.split("\n");
14
- // content = lines
15
- // // .slice(lines.findIndex(Boolean), lines.findLastIndex(Boolean) - 1)
16
- // .slice(lines.findIndex(Boolean), findLastIndex(lines, Boolean) - 1)
17
- // .join("\n");
18
- // @see https://stackoverflow.com/a/72653325/1938970
19
- appendFileSync(i,EOL,"utf8");}// appendFileSync(filepath, EOL, "utf8");
5
+ function fsWriteSync(i,m,n=!0){mkdirSync(dirname(i),{recursive:!0}),writeFileSync(i,m=m.replace(/^\s*/m,"")),n&&appendFileSync(i,EOL,"utf8");}
20
6
 
21
7
  export { fsWriteSync as default, fsWriteSync };
@@ -4,18 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var console = require('console');
6
6
 
7
- /**
8
- *
9
- * @see https://stackoverflow.com/a/41407246/1938970
10
- *
11
- * @usage
12
- * ```ts
13
- * const err = jestCreateExpectedThrownError("@org/pkg", "fnName");
14
- *
15
- * // @ts-expect-error test wrong implementation
16
- * err(() => fnName("wrong arguments implementation"));
17
- * ```
18
- */const jestCreateExpectedThrownError=(r,t)=>o=>{try{o().toThrow(RegExp(`\\[${r}\\]::${t}, .*`,"g"));}catch(o){console.log("\x1b[32m"," ✓","\x1b[0m","throw","\x1b[2m",o.message.replace(`[${r}]::${t}, `,""));}};
7
+ const jestCreateExpectedThrownError=(r,t)=>o=>{try{o().toThrow(RegExp(`\\[${r}\\]::${t}, .*`,"g"));}catch(o){console.log("\x1b[32m"," ✓","\x1b[0m","throw","\x1b[2m",o.message.replace(`[${r}]::${t}, `,""));}};
19
8
 
20
9
  exports.default = jestCreateExpectedThrownError;
21
10
  exports.jestCreateExpectedThrownError = jestCreateExpectedThrownError;
@@ -1,2 +1,14 @@
1
+ /**
2
+ *
3
+ * @see https://stackoverflow.com/a/41407246/1938970
4
+ *
5
+ * @usage
6
+ * ```ts
7
+ * const err = jestCreateExpectedThrownError("@org/pkg", "fnName");
8
+ *
9
+ * // @ts-expect-error test wrong implementation
10
+ * err(() => fnName("wrong arguments implementation"));
11
+ * ```
12
+ */
1
13
  export declare const jestCreateExpectedThrownError: (pkgName: string, fnName: string) => (expectFn: () => ReturnType<jest.Expect>) => void;
2
14
  export default jestCreateExpectedThrownError;
@@ -1,16 +1,5 @@
1
1
  import { log } from 'console';
2
2
 
3
- /**
4
- *
5
- * @see https://stackoverflow.com/a/41407246/1938970
6
- *
7
- * @usage
8
- * ```ts
9
- * const err = jestCreateExpectedThrownError("@org/pkg", "fnName");
10
- *
11
- * // @ts-expect-error test wrong implementation
12
- * err(() => fnName("wrong arguments implementation"));
13
- * ```
14
- */const jestCreateExpectedThrownError=(r,t)=>o=>{try{o().toThrow(RegExp(`\\[${r}\\]::${t}, .*`,"g"));}catch(o){log("\x1b[32m"," ✓","\x1b[0m","throw","\x1b[2m",o.message.replace(`[${r}]::${t}, `,""));}};
3
+ const jestCreateExpectedThrownError=(r,t)=>o=>{try{o().toThrow(RegExp(`\\[${r}\\]::${t}, .*`,"g"));}catch(o){log("\x1b[32m"," ✓","\x1b[0m","throw","\x1b[2m",o.message.replace(`[${r}]::${t}, `,""));}};
15
4
 
16
5
  export { jestCreateExpectedThrownError as default, jestCreateExpectedThrownError };
package/package.json CHANGED
@@ -37,6 +37,6 @@
37
37
  "module": "./index.esm.js",
38
38
  "main": "./index.cjs.js",
39
39
  "types": "./index.esm.d.ts",
40
- "version": "2.0.0-beta.132",
40
+ "version": "2.0.0-beta.134",
41
41
  "dependencies": {}
42
42
  }
@@ -2,15 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- /**
6
- * @category swc
7
- * @param name e.g. `@myorg/mylib` or `@/myprojectlib`
8
- * @param flat Pass `true` for packages where all consumable exports are at the
9
- * root level (no exports from nested folders)
10
- */function swcCreateTransform(r,e=!1){// if (flat) {
11
- // return { [name]: { transform: `${name}/{{member}}` } };
12
- // }
13
- return {[`${r}/?(((\\w*)?/?)*)`]:{transform:`${r}/{{ matches.[1] }}/{{member}}`}}}
5
+ function swcCreateTransform(r,e=!1){return {[`${r}/?(((\\w*)?/?)*)`]:{transform:`${r}/{{ matches.[1] }}/{{member}}`}}}
14
6
 
15
7
  exports.default = swcCreateTransform;
16
8
  exports.swcCreateTransform = swcCreateTransform;
@@ -1,5 +1,11 @@
1
1
  export type SwcTransform<LibName extends string> = Record<`${LibName}/?(((\\w*)?/?)*)`, {
2
2
  transform: `${LibName}/{{ matches.[1] }}/{{member}}`;
3
3
  }>;
4
+ /**
5
+ * @category swc
6
+ * @param name e.g. `@myorg/mylib` or `@/myprojectlib`
7
+ * @param flat Pass `true` for packages where all consumable exports are at the
8
+ * root level (no exports from nested folders)
9
+ */
4
10
  export declare function swcCreateTransform<T extends string>(name: T, _flat?: boolean): SwcTransform<T>;
5
11
  export default swcCreateTransform;
@@ -1,11 +1,3 @@
1
- /**
2
- * @category swc
3
- * @param name e.g. `@myorg/mylib` or `@/myprojectlib`
4
- * @param flat Pass `true` for packages where all consumable exports are at the
5
- * root level (no exports from nested folders)
6
- */function swcCreateTransform(r,e=!1){// if (flat) {
7
- // return { [name]: { transform: `${name}/{{member}}` } };
8
- // }
9
- return {[`${r}/?(((\\w*)?/?)*)`]:{transform:`${r}/{{ matches.[1] }}/{{member}}`}}}
1
+ function swcCreateTransform(r,e=!1){return {[`${r}/?(((\\w*)?/?)*)`]:{transform:`${r}/{{ matches.[1] }}/{{member}}`}}}
10
2
 
11
3
  export { swcCreateTransform as default, swcCreateTransform };
@@ -4,12 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var swcCreateTransform = require('./swcCreateTransform.cjs.js');
6
6
 
7
- /**
8
- * @see https://www.zhoulujun.net/nextjs/advanced-features/compiler.html#modularize-imports
9
- *
10
- * @category tooling
11
- * @category swc
12
- */const swcCreateTransforms=(e,s)=>e.reduce((e,o)=>({...e,...swcCreateTransform.swcCreateTransform(s?`${s}/${o}`:o)}),{});
7
+ const swcCreateTransforms=(e,s)=>e.reduce((e,o)=>({...e,...swcCreateTransform.swcCreateTransform(s?`${s}/${o}`:o)}),{});
13
8
 
14
9
  exports.default = swcCreateTransforms;
15
10
  exports.swcCreateTransforms = swcCreateTransforms;
@@ -3,5 +3,11 @@ import { type SwcTransform } from "./swcCreateTransform";
3
3
  export type SwcTransforms<Names extends string, Prefix extends string> = FlatObjectFirstLevel<{
4
4
  [N in Names]: SwcTransform<`${Prefix}${N}`>;
5
5
  }>;
6
+ /**
7
+ * @see https://www.zhoulujun.net/nextjs/advanced-features/compiler.html#modularize-imports
8
+ *
9
+ * @category tooling
10
+ * @category swc
11
+ */
6
12
  export declare const swcCreateTransforms: <TLibs extends readonly string[], TScope extends string>(libs: TLibs, scope?: TScope) => FlatObjectFirstLevel<{ [N in TLibs[number]]: SwcTransform<`${TScope extends string ? `${TScope}/` : ""}${N}`>; }>;
7
13
  export default swcCreateTransforms;
@@ -1,10 +1,5 @@
1
1
  import { swcCreateTransform } from './swcCreateTransform.esm.js';
2
2
 
3
- /**
4
- * @see https://www.zhoulujun.net/nextjs/advanced-features/compiler.html#modularize-imports
5
- *
6
- * @category tooling
7
- * @category swc
8
- */const swcCreateTransforms=(e,s)=>e.reduce((e,o)=>({...e,...swcCreateTransform(s?`${s}/${o}`:o)}),{});
3
+ const swcCreateTransforms=(e,s)=>e.reduce((e,o)=>({...e,...swcCreateTransform(s?`${s}/${o}`:o)}),{});
9
4
 
10
5
  export { swcCreateTransforms as default, swcCreateTransforms };
@@ -4,15 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var swcCreateTransforms = require('./swcCreateTransforms.cjs.js');
6
6
 
7
- /**
8
- * @see https://www.zhoulujun.net/nextjs/advanced-features/compiler.html#modularize-imports
9
- *
10
- * @category tooling
11
- * @category swc
12
- */const swcTransformsKoine=swcCreateTransforms.swcCreateTransforms(// TODO:FIXME: import the koine packages names froma centralised place, adding
13
- // the packages/libs.ts file to the tsconfig.base.json does not seem to be enough
14
- // import { koineLibs } from "../../libs";
15
- ["api","browser","dom","i18n","next","node","react","utils"],"@koine");// prettier-ignore
7
+ const swcTransformsKoine=swcCreateTransforms.swcCreateTransforms(["api","browser","dom","i18n","next","node","react","utils"],"@koine");
16
8
 
17
9
  exports.default = swcTransformsKoine;
18
10
  exports.swcTransformsKoine = swcTransformsKoine;
@@ -1,3 +1,9 @@
1
+ /**
2
+ * @see https://www.zhoulujun.net/nextjs/advanced-features/compiler.html#modularize-imports
3
+ *
4
+ * @category tooling
5
+ * @category swc
6
+ */
1
7
  export declare const swcTransformsKoine: {
2
8
  "@koine/api/?(((\\w*)?/?)*)": {
3
9
  transform: "@koine/api/{{ matches.[1] }}/{{member}}";
@@ -1,13 +1,5 @@
1
1
  import { swcCreateTransforms } from './swcCreateTransforms.esm.js';
2
2
 
3
- /**
4
- * @see https://www.zhoulujun.net/nextjs/advanced-features/compiler.html#modularize-imports
5
- *
6
- * @category tooling
7
- * @category swc
8
- */const swcTransformsKoine=swcCreateTransforms(// TODO:FIXME: import the koine packages names froma centralised place, adding
9
- // the packages/libs.ts file to the tsconfig.base.json does not seem to be enough
10
- // import { koineLibs } from "../../libs";
11
- ["api","browser","dom","i18n","next","node","react","utils"],"@koine");// prettier-ignore
3
+ const swcTransformsKoine=swcCreateTransforms(["api","browser","dom","i18n","next","node","react","utils"],"@koine");
12
4
 
13
5
  export { swcTransformsKoine as default, swcTransformsKoine };