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

interpolate-es

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

interpolate-es - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

test/compat.spec.cjs

9

index.d.ts

@@ -1,1 +0,8 @@

export { default } from "./src/interpolate.js";
/**
* Interpolate a tagged template literal from the inputs
*
* @param {*} template the template literal string
* @param {*} [tags] the tagged values in the template
* @returns the template output with the tagged literals applied
*/
export default function interpolate(template: any, tags?: any): any;

@@ -1,1 +0,34 @@

export { default } from './src/interpolate.js';
/* eslint-disable no-new-func */
/**
* Interpolate a tagged template literal from the inputs
*
* @param {*} template the template literal string
* @param {*} [tags] the tagged values in the template
* @returns the template output with the tagged literals applied
*/
export default function interpolate (template, tags = {}) {
const keys = Object.keys(tags);
const values = Object.values(tags);
try {
return new Function(...keys, `return \`${template}\`;`)(...values);
} catch (e) {
throw new TemplateException(template, tags, e);
}
}
/**
* @private
*/
class TemplateException extends Error {
constructor (template, tags, message) {
super();
this.name = 'TemplateError';
let msg = '\n------------------\n';
msg += `Template: \`${template}\``;
msg += '\n------------------\n';
msg += `Tags: ${JSON.stringify(tags, null, 2)}`;
msg += '\n------------------\n';
msg += message;
this.message = msg;
}
}

18

package.json
{
"name": "interpolate-es",
"version": "1.2.0",
"version": "1.3.0",
"description": "Dynamically build tagged templates",

@@ -14,12 +14,13 @@ "keywords": [

"repository": "http://github.com/vanillaes/interpolate-es/",
"main": "index.js",
"module": "dist/interpolate.esm.js",
"type": "module",
"main": "index.cjs",
"exports": {
"import": "./index.js",
"require": "./index.cjs"
},
"types": "index.d.ts",
"engines": {
"node": ">=13.2"
},
"scripts": {
"test": "tape-es",
"test:watch": "tape-watch-es",
"test:compat": "node test/compat.spec.cjs",
"lint": "semistandard",

@@ -35,3 +36,3 @@ "types": "npx tsc -p .config/jsconfig.json",

"package": "npx rimraf package && npm pack | tail -n 1 | xargs tar -xf",
"preversion": "npm test && npm run lint && npm run types",
"preversion": "npm test && npm run test:compat && npm run lint && npm run types",
"version": "npm run build",

@@ -45,3 +46,6 @@ "postversion": "git push --follow-tags"

"tape-es": "^1.1.1"
},
"engines": {
"node": ">=13.7"
}
}

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