Registry / productivity / rfs-string-formatter

rfs-string-formatter

JSON →
library0.0.5jsnpmunverified

A lightweight string formatting utility for JavaScript, inspired by C#/.NET style placeholders. Version 0.0.5, last updated in 2018, with no active development. Provides two functions: format() for positional placeholders (supports array or multiple arguments) and formatReplace() for named placeholders. Minimal dependency, simple API, but lacks TypeScript support and modern ESM exports. Best suited for simple string interpolation in legacy Node.js projects.

npm install rfs-string-formatter
INSTALL
IMPORT
SIG · RFS-STRING-FORMATT
R
rfs-string-formatter
productivityjavascriptv0.0.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

format
const formatter = require('rfs-string-formatter'); formatter.format(...)
import { format } from 'rfs-string-formatter';
Package uses CommonJS and does not export named modules; must use default require and call method on returned object.
formatReplace
const formatter = require('rfs-string-formatter'); formatter.formatReplace(...)
import { formatReplace } from 'rfs-string-formatter';
Same as note for format; no named exports.
default
const formatter = require('rfs-string-formatter');
import formatter from 'rfs-string-formatter';
No default export; ESM import is not supported without a build step. Use require.

Demonstrates both format() and formatReplace() with positional (arguments/array) and named placeholders.

const formatter = require('rfs-string-formatter'); // Positional formatting const result1 = formatter.format("Hello {0}, today is {1}", "Alice", "Monday"); console.log(result1); // Hello Alice, today is Monday // With array const result2 = formatter.format("Value1: {0}, Value2: {1}", ["a", "b"]); console.log(result2); // Value1: a, Value2: b // Named placeholders const result3 = formatter.formatReplace("Name: {name}, Age: {age}", { name: "Bob", age: 30 }); console.log(result3); // Name: Bob, Age: 30 // Escaping curly braces is not supported; use '\\{' to escape if needed
Debug
Known issues
gotchaEscaping curly braces or special characters is not supported; attempting to use '\\{' will not produce a literal '{'.
fix
Manually replace '\\{' with '{' after formatting, or use a different library that supports escaping.
affects: <=0.0.5
gotchaIf args array contains undefined elements, they will be coerced to string 'undefined' in the output.
fix
Ensure all array elements are defined, or filter out undefined values before passing to format.
affects: <=0.0.5
deprecatedPackage is unmaintained since 2018; no TypeScript definitions, no ES modules, no bug fixes.
fix
Consider migrating to a maintained alternative like 'string-format' or 'template-format'.
affects: >=0.0.1
Errors
Common errors & fixes
Cannot find module 'rfs-string-formatter'
Package not installed or npm registry issue.
fix
Run 'npm install rfs-string-formatter' and ensure node_modules contains the package.
formatter.format is not a function
Incorrect import style; using named import instead of default require.
fix
Use 'const formatter = require("rfs-string-formatter");' then call formatter.format(...)
Cannot read properties of undefined (reading 'replace')
Template argument is undefined or null.
fix
Ensure the first argument to format/formatReplace is a non-empty string.
Upgrade
Version history
0.0.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
17 hits · last 30 days
node
16
OpenAI (training)
1
Resources
rfs-string-formatter — npm install rfs-string-formatter · libregistry