Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@onflow/util-template

Package Overview
Dependencies
Maintainers
12
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onflow/util-template - npm Package Compare versions

Comparing version 1.2.0-alpha.0 to 1.2.0

.eslintrc.json

13

CHANGELOG.md
# @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 @@

31

dist/template.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc