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

pupa

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pupa

Simple micro templating

  • 2.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.7M
increased by7.62%
Maintainers
1
Weekly downloads
 
Created

What is pupa?

The pupa npm package is a simple string interpolation library. It allows you to replace placeholders in a string with actual values from an object or an array. It is useful for templating and customizing messages or configurations.

What are pupa's main functionalities?

String interpolation with an object

This feature allows you to interpolate values from an object into a string. For example, if you have an object with properties 'name' and 'notifications', pupa can replace the placeholders in the string with the corresponding values from the object.

"Hello, {name}! You have {notifications} new notifications."

String interpolation with an array

This feature allows you to interpolate values from an array into a string. The placeholders are indexed based on the array's indices, allowing you to insert array elements into the string at the specified positions.

"Hello, {0}! You are number {1} in line."

Nested object interpolation

Pupa also supports nested object interpolation, where you can access nested properties within an object to replace placeholders in a string.

"Hello, {user.name}! Your role is {user.role}."

Escape interpolation syntax

If you need to include the interpolation syntax as a literal part of the string, you can escape it using a backslash. This tells pupa not to interpret it as a placeholder.

"This is a message with an escaped placeholder: \{escaped\}"

Other packages similar to pupa

Keywords

FAQs

Package last updated on 21 Oct 2020

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