
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
bracketter
)Parse and manipulate tokenized strings with ease!
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.
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'; |
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,
});
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.']
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.
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
fred.lackey@gmail.com
FAQs
Parse and manipulate tokenized strings with ease!
We found that bracketter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.