
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
variable-injector
Advanced tools
A simple and powerful string replacement utility for TypeScript/Javascript. With this package, you can replace variables in a string with their corresponding values from an object. It supports fully customizable variable identifiers and can handle spaces
The variable-injector package is a powerful tool for replacing variables in strings. It allows you to easily replace variables in a string with their corresponding values, using a flexible and customizable syntax.
{{variable}}, #variable#, or %variable%. Simply pass in your desired syntax as the second argument to the injector() function.To install the Replacer package, simply run the following command:
npm install variable-injector
API Documentation
injector(data: string, variables: { [key: string]: any }, variableIdentifiers: string[] = ["#_#", "{{_}}", "%_%"]): string
This function takes in 3 arguments, the string which needs to be modified, the variables which needs to replace in the string and the variable identifier which is used to find the variables in the string.
Arguments
data (string): The string which needs to be modified.variables (object): An object containing key-value pairs of variables to be replaced in the string. The keys should match the variables used in the data string.variableIdentifiers (string[]): An array of strings that should be used as variable identifiers in the data string. The default value is ["#_#", "{{_}}", "%_%"].import injector from "variable-injector";
const data = "My name is #name# and I am #age# years old";
const variables = { name: "Rayhan", age: 25 };
const modifiedData = injector(data, variables);
console.log(modifiedData);
// Output: "My name is Rayhan and I am 25 years old"
import injector from "variable-injector";
const data = "My name is #name# and I am #age# years old";
const variables = { name: "Rayhan", age: 25 };
const modifiedData = injector(data, variables, ["#_#", "{{_}}"]);
console.log(modifiedData);
// Output: "My name is Rayhan and I am 25 years old"
To test the package, you can use the jest package. Run the command
npm run test
This package is built using TypeScript and it is well documented and tested.
We welcome contributions to the Replacer package. If you have an idea for a new feature or find a bug, please open an issue or submit a pull request on the GitHub repository.
The Replacer package is open-source software licensed under the MIT license.
The Replacer package is a powerful and flexible tool for replacing variables in strings. It's easy to use, supports any data type, and allows you to customize the variable syntax to your liking. Give it a try and see how it can help you in your projects!
FAQs
A simple and powerful string replacement utility for TypeScript/Javascript. With this package, you can replace variables in a string with their corresponding values from an object. It supports fully customizable variable identifiers and can handle spaces
We found that variable-injector 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.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.