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

bracketter

v0.0.4

Published

Parse and manipulate tokenized strings with ease!

Downloads

64

Readme

Bracketter (bracketter)

Parse and manipulate tokenized strings with ease!

Description

So many file types... so many different tagging, wrapping, bracketting characters... <>, </>, [], {}, (), %%, __, etc., etc., etc.

The goal of this library is to provide a one-stop-shop utility for whatever format your tokenized strings are in.

CommonJS or Modules

Two versions of this project exist for your convenience. The main bracketter uses Module format while bracketter-js contains the same logic but written as CommonJS. If you're new to NodeJS, and not sure what you are using, take a look at the syntax you use for loading dependencies:

| Format | Syntax | |--------|--------| | CommonJS | const { replace } = require('bracketter-js'); | | Modules | import { replace } from 'bracketter'; |

Usage

During this experiemental stage, there is one single entrypoint, replace():

const result = replace({ 
  line,     // raw string of tokenized values
  values,   // object of key-value pairs
  defaults  // optional key-value pair object, like values,
});

Or, if you have a multiple lines to replace:

const result = replace({ 
  lines,    // array of strings
  values,   // object of key-value pairs
  defaults  // optional key-value pair object, like values,
});

Example Usage

If you're like me, seeing the code is everything. Here's a quick example to show how you might use the bracketter utility in your project:

import { replace } from '../../index.mjs';

const lines = [
  'Hello {name}! How are you?',
  'Today is %day%.',
];

const values = {
  name: 'World',
}

const defaults = {
  day: 'a great day',
}

const result = replace({ 
  lines,
  values,
  defaults,
});

console.log(result);

That code above will yield:

['Hello World! How are you?', 'Today is a great day.']

Token Nesting

One of the items I use this library for is the nesting of tokenized strings. Not too long ago I leveraged some 12-factor concepts to create a deployment engine for AWS and Azure using Terraform IaC packages. The IaC code had to be built on the fly and constructed by applying multiple layers of logic. Each layer could essentially change the previous for many reasons (security, quota limits, etc.). One of the techniques that allowed me to be successful was allowing each layer to apply concrete changes or new strings which could also be tokenized in preparation for the next stage. Anyway, long story short, bracketter employs this same nesting logic in case you would like to leverage a similar pattern.

Contact Info

This was a quick lil' project I whipped up for something I needed in an opensouce project. If you have interest in bracketter, please let me know so I will know to keep it alive. If there are any enhancements you can think of, I'd love to know that to! Until then...

Fred Lackey
http://fredlackey.com
[email protected]