
Security News
rv Is a New Rust-Powered Ruby Version Manager Inspired by Python's uv
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
paraphrase
Advanced tools
npm i paraphrase
Creates new paraphrase method instance
import { paraphrase } from "paraphrase";
const phrase = paraphrase(/\${([^{}]*)}/gm); // Create a new phrase function using a RegExp match
phrase("Hello, ${name}", { name: "Martin" }); // Hello, Martin
Acceptable replacements (values) are strings and numbers
One or more RegExp replacers, an optional options object at the end
option | meaning | type | default |
---|---|---|---|
recursive | Should continue to resolve result string until replacements have been exhausted | Boolean | true |
resolve | Should resolve dot notations within the template | Boolean | true |
clean | Should remove unmatched template instances | Boolean | false |
const phrase = paraphrase(/\${([^{}]*)}/gm, /\{{([^{}]*)}}/gm);
phrase("Hello, ${firstname} {{lastname}}", {
firstname: "Martin",
lastname: "Prince",
}); // Hello, Martin Prince
Treat dots as part of the key instead of notation marks
const phrase = paraphrase(/\${([^{}]*)}/gm, { resolve: false });
phrase("Hello, ${name} ${last.name}", {
name: "Martin",
"last.name": "Prince",
}); // Hello, Martin Prince
Remove unmatched template instances from the result string
const phrase = paraphrase(/\${([^{}]*)}/gm, { clean: true });
phrase("Hello, ${firstname} ${lastname}", { firstname: "Martin" }); // Hello, Martin
phrase("Hello, ${name}", { name: "Martin" }); // Hello, Martin
const user = {
name: { first: "Martin", last: "Prince" },
};
phrase("Hello, ${name.first} ${name.last}", user); // Hello, Martin Prince
phrase("Hello, ${0} ${1}", ["Martin", "Prince"]); // Hello, Martin Prince
phrase("Hello, ${0} ${1}", "Martin", "Prince"); // Hello, Martin Prince
${...}
import { dollar as phrase } from "paraphrase";
phrase("Hello, ${name}", { name: "Martin" }); // Hello, Martin
{{...}}
import { double as phrase } from "paraphrase";
phrase("Hello, {{name}}", { name: "Martin" }); // Hello, Martin
{...}
import { single as phrase } from "paraphrase";
phrase("Hello, {name}", { name: "Martin" }); // Hello, Martin
%{...}
(i18n style)import { percent as phrase } from "paraphrase";
phrase("Hello, %{name}", { name: "Martin" }); // Hello, Martin
#{...}
(ruby style)import { hash as phrase } from "paraphrase";
phrase("Hello, #{name}", { name: "Martin" }); // Hello, Martin
import { loose as phrase } from 'paraphrase';
phrase('Hello, #{name.first} {name.last}', {name: { first: 'Martin', last: 'Prince' }); // Hello, Martin Prince
A paraphrase instance exposes view to its patterns array (immutable)
import { hash as phrase } from "paraphrase";
phrase.patterns; // [ /#{([^{}]*)}/gm ]
FAQs
🧩 Create flavoured string template interpolation
The npm package paraphrase receives a total of 1,608 weekly downloads. As such, paraphrase popularity was classified as popular.
We found that paraphrase demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.