{"id":21556575,"url":"https://github.com/fredlackey/bracketter","last_synced_at":"2025-03-18T03:21:44.896Z","repository":{"id":180814040,"uuid":"665638386","full_name":"FredLackey/bracketter","owner":"FredLackey","description":"Parse and manipulate tokenized strings","archived":false,"fork":false,"pushed_at":"2023-07-13T09:46:55.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-26T13:24:44.875Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FredLackey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-12T16:42:54.000Z","updated_at":"2023-07-12T23:52:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"0ce4fe3b-9edf-4761-9c39-5bdd31acf61e","html_url":"https://github.com/FredLackey/bracketter","commit_stats":null,"previous_names":["fredlackey/bracketter"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FredLackey%2Fbracketter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FredLackey%2Fbracketter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FredLackey%2Fbracketter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FredLackey%2Fbracketter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FredLackey","download_url":"https://codeload.github.com/FredLackey/bracketter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244147384,"owners_count":20405952,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-24T08:09:14.734Z","updated_at":"2025-03-18T03:21:44.887Z","avatar_url":"https://github.com/FredLackey.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bracketter ([`bracketter`](https://github.com/FredLackey/bracketter))\n\nParse and manipulate tokenized strings with ease!\n\n## Description\n\nSo many file types... so many different tagging, wrapping, bracketting characters... `\u003c\u003e`, `\u003c/\u003e`, `[]`, `{}`, `()`, `%%`, `__`, etc., etc., etc.\n\nThe goal of this library is to provide a one-stop-shop utility for whatever format your tokenized strings are in.\n\n## CommonJS or Modules\n\nTwo versions of this project exist for your convenience.  The main [`bracketter`](https://github.com/FredLackey/bracketter) uses Module format while [`bracketter-js`](https://github.com/FredLackey/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:\n\n| Format | Syntax |\n|--------|--------|\n| CommonJS | `const { replace } = require('bracketter-js');` |\n| Modules | `import { replace } from 'bracketter';` |\n\n## Usage\n\nDuring this experiemental stage, there is one single entrypoint, `replace()`:\n\n```\nconst result = replace({ \n  line,     // raw string of tokenized values\n  values,   // object of key-value pairs\n  defaults  // optional key-value pair object, like values,\n});\n```\nOr, if you have a multiple lines to replace:\n\n```\nconst result = replace({ \n  lines,    // array of strings\n  values,   // object of key-value pairs\n  defaults  // optional key-value pair object, like values,\n});\n```\n\n## Example Usage\n\nIf you're like me, seeing the code is everything.  Here's a quick example to show how you might use the [`bracketter`](https://github.com/FredLackey/bracketter) utility in your project:\n\n```\nimport { replace } from '../../index.mjs';\n\nconst lines = [\n  'Hello {name}! How are you?',\n  'Today is %day%.',\n];\n\nconst values = {\n  name: 'World',\n}\n\nconst defaults = {\n  day: 'a great day',\n}\n\nconst result = replace({ \n  lines,\n  values,\n  defaults,\n});\n\nconsole.log(result);\n```\nThat code above will yield:\n```\n['Hello World! How are you?', 'Today is a great day.']\n```\n\n## Token Nesting\n\nOne of the items I use this library for is the nesting of tokenized strings.  Not too long ago I leveraged some [12-factor concepts](https://12factor.net/) 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`](https://github.com/FredLackey/bracketter) employs this same nesting logic in case you would like to leverage a similar pattern.\n\n## Contact Info\n\nThis was a quick lil' project I whipped up for something I needed in an opensouce project.  If you have interest in [`bracketter`](https://github.com/FredLackey/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...\n\n**Fred Lackey**  \n**[http://fredlackey.com](http://fredlackey.com)**  \n**[fred.lackey@gmail.com](mailto:fred.lackey@gmail.com)**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffredlackey%2Fbracketter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffredlackey%2Fbracketter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffredlackey%2Fbracketter/lists"}