npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

simple-placeholder-replacer

v1.1.0

Published

A simple placeholder replacer

Downloads

13

Readme

simple-placeholder-replacer

Build Status Coverage Status dependencies Status devDependencies Status Known Vulnerabilities

Npm version Npm downloads Npm download size Last Commit Contributors

A library to replace placeholders in a json/string object. You have to use double curly brackets {{placeholderKey}} to identify the placeholder and proivide a map with pairs of key / value where the key is the name of the placeholder (case doesn't matter) and value is the replacement value for that placeholder. The library can also handle date / date time placeholders that are {{now}} or {{today}} (again case doesn't matter) and that can be configured with the following options :

  • a number of units to add / subtract to the system date / time e.g. {{today+1d}} -> will cause the library to replace this tag with the system date + one day Note that the unit is not mandatory, days will be the unit by default for {{today}} and hours for {{now}}

    Available units for {{today}} are :

      - d / D : days
      - m / M : months
      - y / Y : years
      - w / W : weeks
        

    Available units for {{now}} are :

      - h / H : hours
      - m / M : minutes
      - s / S : seconds
        
  • the desired output format for the date / date time e.g. {{now=HH:MM:SS}} -> will output the current time Note that the format must be compatible with formats recognized by the moment js library

    Default formats are :

      - {{today}} -> YYYY-MM-DD
      - {{now}}   -> YYYY-MM-DDTHH:MM:SS

Installation

To install with npm:

npm i simple-placeholder-replacer --save

Usage

Usage with node:

var replacePlaceholders = require('simple-placeholder-replacer');

replacePlaceholders('I want {{myPlaceholder}} to be replaced', {myPlaceholder: 'this placeholder'});

--> 'I want this placeholder to be replaced'

replacePlaceholders({"myDate": "{{today+1m=DD MM YYYY}}"});

--> assulming today is the 11-03-2021 : {"myDate": "11 04 2021"}

Release

npm version major / minor / patch
git push origin ${tagName}

License

This is licensed under an MIT License. See details