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

literal-toast

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

literal-toast

Helper for making template literal tags; combines template literal values so you don't have to

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
35
decreased by-62.77%
Maintainers
1
Weekly downloads
 
Created
Source

🍞 Literal Toast

npm literal-toast Build Status codecov

Helper for making template literal tags; combines template literal values so you don't have to

Wait, what ⁉️

Tagged template literals are a feature of ES6/ES2015 which allows processing of template literals (template strings).

This is a little helper for zipping the literals and substitutions so your tag can operate on or return the final value of the template string without reimplementing this logic itself.

Usage

Spread the literals and substitutions from the template literal onto literalToast;

import literalToast from 'literal-toast';

function lineReverse(literals, ...substitutions) {
  return literalToast(literals, ...substitutions)
    .split('\n')
    .reverse()
    .join('\n');
}

lineReverse`but it demonstrates what this does pretty simply.
This is a weird example,`;

// Returns:
// "This is a weird example,
//  but it demonstrates what this does pretty simply."

The above example shows both the literals and substitutions for clarity, but if you don't use either parameter yourself, you can write it like this instead;

function myTag(...literalValues) {
  return literalToast(...literalValues) // your logic here
}

FAQs

Package last updated on 20 Oct 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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