1.0.3 • Published 12 months ago

strtr-from-php v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

strtr-from-php

npm version npm downloads

This package is a TypeScript implementation of the strtr function from PHP, replicates both from, to and replace_pairs modes exactly.

Install

npm i strtr-from-php

Usage

import { strtr } from 'strtr-from-php';

// Character-to-character replacement
strtr('abcdef', 'abc', 'xyz'); // 'xyzdef'

// Substring replacement
strtr('Hello World', {
	Hello: 'X',
	World: 'Planet',
}); // 'X Planet'

// Complex replacements
strtr('start middle end', {
	start: 'begin',
	middle: 'center',
	end: 'stop',
	'begin center stop': 'complete',
}); // 'begin center stop'

License

MIT License

1.0.3

12 months ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago