Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rimiti/stimmy
:sunglasses: Replace your string variables by your values easily.
https://github.com/rimiti/stimmy
es6 flowtype javascript string variable
Last synced: about 5 hours ago
JSON representation
:sunglasses: Replace your string variables by your values easily.
- Host: GitHub
- URL: https://github.com/rimiti/stimmy
- Owner: rimiti
- License: mit
- Created: 2018-01-13T17:38:36.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-04-25T13:50:54.000Z (over 1 year ago)
- Last Synced: 2024-05-01T13:28:52.874Z (6 months ago)
- Topics: es6, flowtype, javascript, string, variable
- Language: TypeScript
- Homepage:
- Size: 564 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# stimmy
[![Build][build-badge]][build]
[![License][license-badge]][license]
[![PRs Welcome][prs-badge]][prs]## Description
This module provides a string variables replacer.
## Install
```bash
$ yarn add @rimiti/stimmy
```## Features
- Can replace variables from an object.
- Can replace variables from an array.## Documentation
* [From an array](#fromArray)
* [From an object](#fromObject)## Examples
**From import**
```javascript
import { stimmy } from '@rimiti/stimmy';
```**From require**
```javascript
const { stimmy } = require('@rimiti/stimmy');
```
**init pattern**
```javascript
// As default, use the {myVariable} pattern
const replacer = stimmy();// If you want to customized default pattern (ex: {{myVariable}}
const replacer = stimmy('{{', '}}')
```### From an array
```javascript
const str = replacer('This {0} is {1}!', ['module', 'awesome']);
// This module is awesome!
``````javascript
const str = replacer('{0}% of code coverage, it\'s {1}...', [100, 'so amazing']);
// 100% of code coverage, it's so amazing...
```### From an object
```javascript
const str = replacer('{timmy} My hobby is {hobby}...', {timmy: 'Timmmmmmmyy !!', hobby: 'running'});
// Timmmmmmmyy !! My hobby is running...
``````javascript
const str = replacer('My name is {name}, I\'m {age}.', {name: 'stimmy', age: 25});
// My name is stimmy, I'm 25.
```## Scripts
Run using yarn run `` command.
clean - Remove temporarily folders.
build - Compile source files.
build:watch - Interactive watch mode, compile sources on change.
lint - Lint source files.
lint:fix - Fix lint source files.
test - Runs all tests with coverage.
test:watch - Interactive watch mode, runs tests on change.## License
MIT © [Dimitri DO BAIRRO](https://github.com/rimiti/stimmy/blob/master/LICENSE)[build-badge]: https://github.com/rimiti/stimmy/workflows/Test/badge.svg
[build]: https://github.com/rimiti/stimmy/actions?query=workflow%3ATest+branch%3Amaster
[license-badge]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square
[license]: https://github.com/rimiti/stimmy/blob/master/LICENSE
[prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square
[prs]: http://makeapullrequest.com