{"id":12137,"library":"textr","title":"textr","description":"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.","status":"abandoned","version":"0.3.0","language":"javascript","source_language":"en","source_url":"https://github.com/shuvalov-anton/textr","tags":["javascript","typographic","textr","transformer","text"],"install":[{"cmd":"npm install textr","lang":"bash","label":"npm"},{"cmd":"yarn add textr","lang":"bash","label":"yarn"},{"cmd":"pnpm add textr","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","wrong":"import textr from 'textr';","symbol":"textr","correct":"const textr = require('textr');"},{"note":"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.","wrong":"textr.use(pluginFunction);","symbol":"tf.use","correct":"tf.use(pluginFunction);"},{"note":"textr supports using native `String.prototype` methods directly as transform functions, where `this` inside the function refers to the text being processed.","symbol":"String.prototype methods as transforms","correct":"tf.use(String.prototype.trim);"}],"quickstart":{"code":"const textr = require('textr');\nconst ellipses = require('typographic-ellipses');\nconst spaces = require('typographic-single-spaces');\nconst quotes = require('typographic-quotes');\n\n// Create a new text transformer instance, optionally with default options\nconst tf = textr({ locale: 'ru' })\n  .use(ellipses) // Add a plugin for ellipses\n  .use(spaces)   // Add a plugin for single spaces\n  .use(quotes)   // Add a plugin for smart quotes\n  .use(String.prototype.trim); // Use a native String prototype method\n\n// Process text using the configured transformer\nconst input = 'Hello  \"world\"...\\n  This is some text with   bad  spacing and unsmart quotes. '; \nconst output = tf(input);\n\nconsole.log(output); // Expected: Hello «world»… This is some text with bad spacing and unsmart quotes.\n","lang":"javascript","description":"This quickstart demonstrates how to initialize `textr` with options, register multiple typographic plugins, and process a string through the transformation pipeline."},"warnings":[{"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.","message":"The `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.","severity":"gotcha","affected_versions":"<=0.3.0"},{"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.","message":"In 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.","severity":"breaking","affected_versions":">=0.3.0"},{"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.","message":"As 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.","severity":"gotcha","affected_versions":"<=0.3.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"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();`.","cause":"Attempting to instantiate `textr` using `new textr()` or incorrect CommonJS import syntax for a default export, or treating `require('textr')` as a constructor.","error":"TypeError: textr is not a function"},{"fix":"First create a transformer instance using `const tf = textr();`, then call `tf.use(plugin);`.","cause":"Calling `.use()` on the raw `textr` function instead of an instantiated transformer object.","error":"TypeError: tf.use is not a function"}],"ecosystem":"npm"}