😎 Replace your string variables by your values easily.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
__tests__
src
.babelrc
.codeclimate.yml
.editorconfig
.eslintignore
.eslintrc
.flowconfig
.gitignore
.npmignore
.travis.yml
LICENSE
README.md
package-lock.json
package.json

README.md

stimmy

Dependencies Code Climate score Codecov Code Climate issue Build Status MIT License PRs Welcome

Description

This module provides a string variables replacer.

Install

$ npm install @rimiti/stimmy --save

Features

  • Can replace variables from an object.
  • Can replace variables from an array.

Documentation

Examples

From import

import stimmy from '@rimiti/stimmy';

From require

const stimmy = require('@rimiti/stimmy');

init pattern

// As default, use the {myVariable} pattern
const replacer = stimmy();

// If you want to customized default pattern (ex: {{myVariable}}
const replacer = stimmy('{{', '}}')

From an array

const str = replacer('This {0} is {1}!', ['module', 'awesome']);
// This module is awesome!
const str = replacer('{0}% of code coverage, it\'s {1}...', [100, 'so amazing']);
// 100% of code coverage, it's so amazing...

From an object

const str = replacer('{timmy} My hobby is {hobby}...', {timmy: 'Timmmmmmmyy !!', hobby: 'running'});
// Timmmmmmmyy !! My hobby is running...
const str = replacer('My name is {name}, I\'m {age}.', {name: 'stimmy', age: 25});
// My name is stimmy, I'm 25.

Scripts

Run using npm run <script> command.

clean - remove coverage data, Jest cache and transpiled files,
lint - lint source files and tests,
typecheck - check type annotations,
test - lint, typecheck and run tests with coverage,
test-only - run tests with coverage,
test:watch - interactive watch mode to automatically re-run tests,
build - compile source files,
build:watch - interactive watch mode, compile sources on change.

License

MIT © Dimitri DO BAIRRO