@onflow/util-template
Advanced tools
Comparing version 1.2.0-alpha.0 to 1.2.0
# @onflow/util-template | ||
## 1.2.0 | ||
### Minor Changes | ||
- [#1728](https://github.com/onflow/fcl-js/pull/1728) [`a4f8c00c`](https://github.com/onflow/fcl-js/commit/a4f8c00c4cf292d3a4afac610dedbc89ff3affea) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build | ||
- [#1750](https://github.com/onflow/fcl-js/pull/1750) [`845ffa75`](https://github.com/onflow/fcl-js/commit/845ffa756e07188557d150cdb9ff7af59019a477) Thanks [@jribbink](https://github.com/jribbink)! - Convert to Typescript | ||
### Patch Changes | ||
- Updated dependencies [[`a4f8c00c`](https://github.com/onflow/fcl-js/commit/a4f8c00c4cf292d3a4afac610dedbc89ff3affea), [`845ffa75`](https://github.com/onflow/fcl-js/commit/845ffa756e07188557d150cdb9ff7af59019a477)]: | ||
- @onflow/util-logger@1.3.0 | ||
## 1.2.0-alpha.0 | ||
@@ -4,0 +17,0 @@ |
@@ -7,2 +7,9 @@ 'use strict'; | ||
/** | ||
* Interleaves two arrays | ||
* @param a - The first array | ||
* @param b - The second array | ||
* @param c - The target array | ||
* @returns The interleaved array | ||
*/ | ||
function interleave() { | ||
@@ -14,3 +21,6 @@ let a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; | ||
if (!a.length) return c; | ||
if (!b.length) return [...c, a[0]]; | ||
if (!b.length) { | ||
c.push(...a); | ||
return c; | ||
} | ||
const [aHead, ...aRest] = a; | ||
@@ -22,2 +32,8 @@ const [bHead, ...bRest] = b; | ||
} | ||
/** | ||
* Recursively apply a value to a function | ||
* @param d - The value to apply | ||
* @returns A function that takes a function and applies the value to it | ||
*/ | ||
function recApply(d) { | ||
@@ -38,5 +54,6 @@ return function (arg1) { | ||
/** | ||
* @param {(string|Array.<*>)} head | ||
* @param {Array.<*>} rest | ||
* @returns {{function(): string}} | ||
* Creates a template function | ||
* @param head - A string, template string array, or template function | ||
* @param rest - The rest of the arguments | ||
* @returns A template function | ||
*/ | ||
@@ -48,6 +65,4 @@ function template(head) { | ||
if (typeof head === "string") return () => head; | ||
if (Array.isArray(head)) { | ||
return d => interleave(head, rest.map(recApply(d))).join("").trim(); | ||
} | ||
return head; | ||
if (typeof head === "function") return head; | ||
return x => interleave([...head], rest.map(recApply(x))).join("").trim(); | ||
} | ||
@@ -54,0 +69,0 @@ |
import { log } from '@onflow/util-logger'; | ||
/** | ||
* Interleaves two arrays | ||
* @param a - The first array | ||
* @param b - The second array | ||
* @param c - The target array | ||
* @returns The interleaved array | ||
*/ | ||
function interleave() { | ||
@@ -9,3 +16,6 @@ let a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; | ||
if (!a.length) return c; | ||
if (!b.length) return [...c, a[0]]; | ||
if (!b.length) { | ||
c.push(...a); | ||
return c; | ||
} | ||
const [aHead, ...aRest] = a; | ||
@@ -17,2 +27,8 @@ const [bHead, ...bRest] = b; | ||
} | ||
/** | ||
* Recursively apply a value to a function | ||
* @param d - The value to apply | ||
* @returns A function that takes a function and applies the value to it | ||
*/ | ||
function recApply(d) { | ||
@@ -33,5 +49,6 @@ return function (arg1) { | ||
/** | ||
* @param {(string|Array.<*>)} head | ||
* @param {Array.<*>} rest | ||
* @returns {{function(): string}} | ||
* Creates a template function | ||
* @param head - A string, template string array, or template function | ||
* @param rest - The rest of the arguments | ||
* @returns A template function | ||
*/ | ||
@@ -43,6 +60,4 @@ function template(head) { | ||
if (typeof head === "string") return () => head; | ||
if (Array.isArray(head)) { | ||
return d => interleave(head, rest.map(recApply(d))).join("").trim(); | ||
} | ||
return head; | ||
if (typeof head === "function") return head; | ||
return x => interleave([...head], rest.map(recApply(x))).join("").trim(); | ||
} | ||
@@ -49,0 +64,0 @@ |
@@ -7,2 +7,9 @@ (function (global, factory) { | ||
/** | ||
* Interleaves two arrays | ||
* @param a - The first array | ||
* @param b - The second array | ||
* @param c - The target array | ||
* @returns The interleaved array | ||
*/ | ||
function interleave() { | ||
@@ -14,3 +21,6 @@ let a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; | ||
if (!a.length) return c; | ||
if (!b.length) return [...c, a[0]]; | ||
if (!b.length) { | ||
c.push(...a); | ||
return c; | ||
} | ||
const [aHead, ...aRest] = a; | ||
@@ -22,2 +32,8 @@ const [bHead, ...bRest] = b; | ||
} | ||
/** | ||
* Recursively apply a value to a function | ||
* @param d - The value to apply | ||
* @returns A function that takes a function and applies the value to it | ||
*/ | ||
function recApply(d) { | ||
@@ -38,5 +54,6 @@ return function (arg1) { | ||
/** | ||
* @param {(string|Array.<*>)} head | ||
* @param {Array.<*>} rest | ||
* @returns {{function(): string}} | ||
* Creates a template function | ||
* @param head - A string, template string array, or template function | ||
* @param rest - The rest of the arguments | ||
* @returns A template function | ||
*/ | ||
@@ -48,6 +65,4 @@ function template(head) { | ||
if (typeof head === "string") return () => head; | ||
if (Array.isArray(head)) { | ||
return d => interleave(head, rest.map(recApply(d))).join("").trim(); | ||
} | ||
return head; | ||
if (typeof head === "function") return head; | ||
return x => interleave([...head], rest.map(recApply(x))).join("").trim(); | ||
} | ||
@@ -54,0 +69,0 @@ |
{ | ||
"name": "@onflow/util-template", | ||
"version": "1.2.0-alpha.0", | ||
"version": "1.2.0", | ||
"description": "Template Literal used for Cadence Interop", | ||
@@ -16,9 +16,16 @@ "license": "Apache-2.0", | ||
"devDependencies": { | ||
"@onflow/fcl-bundle": "^1.4.0-alpha.0", | ||
"@babel/preset-typescript": "^7.22.5", | ||
"@onflow/fcl-bundle": "^1.4.0", | ||
"@types/jest": "^29.5.3", | ||
"@typescript-eslint/eslint-plugin": "^6.4.0", | ||
"@typescript-eslint/parser": "^6.4.0", | ||
"eslint": "^8.47.0", | ||
"eslint-plugin-jsdoc": "^46.4.6", | ||
"jest": "^29.5.0" | ||
}, | ||
"source": "src/template.js", | ||
"source": "src/template.ts", | ||
"main": "dist/template.js", | ||
"module": "dist/template.module.js", | ||
"unpkg": "dist/template.umd.js", | ||
"types": "dist/template.d.ts", | ||
"scripts": { | ||
@@ -32,4 +39,5 @@ "prepublishOnly": "npm test && npm run build", | ||
"dependencies": { | ||
"@babel/runtime": "^7.18.6" | ||
"@babel/runtime": "^7.18.6", | ||
"@onflow/util-logger": "^1.3.0" | ||
} | ||
} |
@@ -9,4 +9,5 @@ { | ||
// next to the .js files | ||
"outDir": "types", | ||
} | ||
} | ||
"outDir": "types" | ||
}, | ||
"exclude": ["src/__snapshots__"] | ||
} |
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
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
30335
15
232
0
0
2
8
+ Added@onflow/util-logger@^1.3.0
+ Added@onflow/util-logger@1.3.3(transitive)