Registry / serialization / textr
library0.3.0jsnpmunverified

textr is a tiny and extendable framework designed for composing text transformation functions. Its core idea revolves around enabling developers to build modular typography tools by chaining small, single-responsibility text processing modules. The package encourages creating specific transformers for tasks like smart quotes, ellipses, or em-dashes, rather than a monolithic typographic engine. The current stable version is 0.3.0, released in 2015. Given its age and lack of updates, it's considered an abandoned project, meaning no new features or maintenance fixes are expected. Its key differentiator was its pluggable architecture for highly customized text processing workflows, allowing users to combine various `typographic-*` packages available on npm.

npm install textr
INSTALL
IMPORT
SIG · TEXTR
T
textr
serializationjavascriptv0.3.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

textr
const textr = require('textr');
import textr from 'textr';
textr was published in 2015 (v0.3.0) and primarily targets CommonJS environments. While modern Node.js environments can sometimes `import` CommonJS modules, `require()` is the intended and most reliable way to use it.
tf.use
tf.use(pluginFunction);
textr.use(pluginFunction);
The `.use()` method is called on an *instance* of the text transformer created by `textr()`, not on the `textr` function itself. It's used to register transformation middleware.
String.prototype methods as transforms
tf.use(String.prototype.trim);
textr supports using native `String.prototype` methods directly as transform functions, where `this` inside the function refers to the text being processed.

This quickstart demonstrates how to initialize `textr` with options, register multiple typographic plugins, and process a string through the transformation pipeline.

const textr = require('textr'); const ellipses = require('typographic-ellipses'); const spaces = require('typographic-single-spaces'); const quotes = require('typographic-quotes'); // Create a new text transformer instance, optionally with default options const tf = textr({ locale: 'ru' }) .use(ellipses) // Add a plugin for ellipses .use(spaces) // Add a plugin for single spaces .use(quotes) // Add a plugin for smart quotes .use(String.prototype.trim); // Use a native String prototype method // Process text using the configured transformer const input = 'Hello "world"...\n This is some text with bad spacing and unsmart quotes. '; const output = tf(input); console.log(output); // Expected: Hello «world»… This is some text with bad spacing and unsmart quotes.
Debug
Known issues
gotchaThe `textr` package has not been updated since April 2015 (version 0.3.0). This means it likely lacks support for modern JavaScript features (like native ESM) and may have unpatched security vulnerabilities or compatibility issues with newer Node.js versions or ecosystems. Consider alternatives for active projects.
fix
For new projects, evaluate actively maintained typographic or text-processing libraries. If `textr` is essential, thorough testing in your target environment and auditing dependencies is recommended.
affects: <=0.3.0
breakingIn version 0.3.0, the `tf.exec` method's signature changed to accept `options` as a second argument. If you were calling `tf.exec(text)` and relying on `options` being passed implicitly or not existing, your code might break or behave unexpectedly.
fix
Update calls to `tf.exec(text)` to `tf.exec(text, currentOptions)` where `currentOptions` is an object of relevant options. Plugins should also expect `options` as the second argument.
affects: >=0.3.0
gotchaAs an older CommonJS-era library, `textr` does not natively support ES Modules (`import`). While Node.js can sometimes interop, direct `require()` is the only reliable way to use it. Attempting `import textr from 'textr'` in an ESM context may lead to unexpected behavior or errors in bundlers or native ESM environments.
fix
Use `const textr = require('textr');`. For ESM-only projects, you might need to use dynamic `import()` or rely on bundler configurations to handle CommonJS modules. Consider using a CommonJS wrapper if consistent ESM syntax is critical.
affects: <=0.3.0
Errors
Common errors & fixes
TypeError: textr is not a function
Attempting to instantiate `textr` using `new textr()` or incorrect CommonJS import syntax for a default export, or treating `require('textr')` as a constructor.
fix
The `textr` package exports a function directly. Use `const textr = require('textr');` and then call `textr()` to create an instance, e.g., `const tf = textr();`.
TypeError: tf.use is not a function
Calling `.use()` on the raw `textr` function instead of an instantiated transformer object.
fix
First create a transformer instance using `const tf = textr();`, then call `tf.use(plugin);`.
Upgrade
Version history
0.3.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
textr — npm install textr · libregistry