https://github.com/dunks1980/stringsticker
https://github.com/dunks1980/stringsticker
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/dunks1980/stringsticker
- Owner: Dunks1980
- License: mit
- Created: 2024-02-03T16:15:05.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-03T23:51:13.000Z (over 2 years ago)
- Last Synced: 2025-03-03T07:18:51.746Z (over 1 year ago)
- Language: JavaScript
- Size: 8.79 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
#
stringsticker.js
[](https://npmjs.org/package/@dunks1980/stringsticker.js)
[](https://snyk.io/test/github/dunks1980/stringsticker.js?targetFile=package.json)
[](https://raw.githubusercontent.com/Dunks1980/stringsticker/main/LICENSE)
[](https://www.jsdelivr.com/package/npm/@dunks1980/stringsticker.js)
## What is stringsticker.js?
Stringsticker is a tool for rearranging strings into a different format while retaining parts of the string that may contain variables or other dynamic content.
## Installation
stringsticker.js can be used via a script tag or importing as a module.
#### Script tag:
```html
```
#### ES Module:
```html
```
```javascript
// In main.js
import ss from '//cdn.jsdelivr.net/npm/@dunks1980/stringsticker.js/stringsticker.mjs';
```
You may want to add a version number like this to prevent breaking changes: '//cdn.jsdelivr.net/npm/@dunks1980/stringsticker.js@< VERSION >/stringsticker.mjs' the version number is optional and can be acquired from going to the npm package page. Or if using node_modules: './node_modules/@dunks1980/stringsticker.js/stringsticker.mjs';
#### NPM Module:
```javascript
npm i @dunks1980/stringsticker.js
import ss from '@dunks1980/stringsticker.js';
ss();
```
## Usage
```js
const output1 = ss(
"Then she visited her grandmother on Sunday.",
"{{1}} {{2}} {{3}} {{4}} {{5}} {{6}} {{7}}.",
"{{1}} {{6}} {{7}} {{2}} {{3}} {{4}} {{5}}."
);
console.log(output1); // Then on Sunday she visited her grandmother.
const output2 = ss(
"12/11/2024",
"{{day}}/{{month}}/{{year}}",
"{{year}}-{{month}}-{{day}}"
);
console.log(output2); // 2024-11-12
```
## Demo
https://codepen.io/Dunks1980/pen/rNRvZwe