New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jsonlit

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonlit

Template literal tag function that JSON.stringify(expressions)

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

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

JSON template literal tag

Template literal tag function that escapes arguments as JSON values. Zero dependency. Supports both ESM and CJS.

jlit uses JSON.stringify() to escape the template literal's arguments.

Usage:
import {jlit} from 'jlit'

jlit`string:  ${'double quote "'}`
jlit`number:  ${1337}`
jlit`boolean: ${true} & ${false}`
jlit`null:    ${null}`
jlit`array:   ${['double quote "', null, 1337]}`
jlit`object:  ${{doubleQuote: '"', doubleNumber: 1.337e+3}}`

You will get the following strings:

string:  "double quote \""
number:  1337
boolean: true & false
null:    null
array:   ["double quote \"",null,1337]
object:  {"doubleQuote":"\"","doubleNumber":1337}

It works as follows, this:

jlit`text ${value}`

Is essentialy this:

`text ${JSON.stringify(value)}`

Keywords

FAQs

Package last updated on 04 Feb 2023

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