Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rimiti/stimmy

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rimiti/stimmy - npm Package Compare versions

Comparing version 1.9.0 to 1.10.0

dist/index.d.ts

47

dist/index.js
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
function _default(start = '{', end = '}') {
// remove RegExp specials
const theStart = start.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
const theEnd = end.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
const arrayReg = new RegExp(`(${theStart}(.+?)${theEnd})`, 'g');
const objectReg = new RegExp(`(${theStart}([^}]+)${theEnd})`, 'g');
const startReg = new RegExp(`${theStart}`, 'g');
const endReg = new RegExp(`${theEnd}`, 'g');
return (value, items) => {
if (typeof value === 'string' && items instanceof Array) {
// $FlowFixMe: Flow doesn't understand computed values
return value.replace(arrayReg, i => items[i.replace(startReg, '').replace(endReg, '')]);
}
if (typeof value === 'string' && items instanceof Object) {
return value.replace(objectReg, i => {
const key = i.replace(startReg, '').replace(endReg, ''); // $FlowFixMe: Flow doesn't understand computed values
if (!items[key]) return i;
return items[key];
});
}
return value;
};
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJuYW1lcyI6WyJzdGFydCIsImVuZCIsInRoZVN0YXJ0IiwicmVwbGFjZSIsInRoZUVuZCIsImFycmF5UmVnIiwiUmVnRXhwIiwib2JqZWN0UmVnIiwic3RhcnRSZWciLCJlbmRSZWciLCJ2YWx1ZSIsIml0ZW1zIiwiQXJyYXkiLCJpIiwiT2JqZWN0Iiwia2V5Il0sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBQ2Usa0JBQVVBLEtBQWEsR0FBRyxHQUEx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zdGFydFJlZyA9IG5ldyBSZWdFeHAoYCR7dGhlU3RhcnR9YCwgJ2cnKTtcbiAgY29uc3QgZW5kUmVnID0gbmV3IFJlZ0V4cChgJHt0aGVFbmR9YCwgJ2cnKTtcblxuICByZXR1cm4gKHZhbHVlOiBzdHJpbmcsIGl0ZW1zOiBBcnJheTxtaXhlZD4gfCBPYmplY3QpOiBzdHJpbmcgPT4ge1xuICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICdzdHJpbmcnICYmIGl0ZW1zIGluc3RhbmNlb2YgQXJyYXkpIHtcbiAgICAgIC8vICRGbG93Rml4TWU6IEZsb3cgZG9lc24ndCB1bmRlcnN0YW5kIGNvbXB1dGVkIHZhbHVlc1xuICAgICAgcmV0dXJuIHZhbHVlLnJlcGxhY2UoYXJyYXlSZWcsIChpKSA9PiBpdGVtc1tpLnJlcGxhY2Uoc3RhcnRSZWcsICcnKS5yZXBsYWNlKGVuZFJlZywgJycpXSk7XG4gICAgfVxuXG4gICAgaWYgKHR5cGVvZiB2YWx1ZSA9PT0gJ3N0cmluZycgJiYgaXRlbXMgaW5zdGFuY2VvZiBPYmplY3QpIHtcbiAgICAgIHJldHVybiB2YWx1ZS5yZXBsYWNlKG9iamVjdFJlZywgKGkpID0+IHtcbiAgICAgICAgY29uc3Qga2V5ID0gaS5yZXBsYWNlKHN0YXJ0UmVnLCAnJykucmVwbGFjZShlbmRSZWcsICcnKTtcbiAgICAgICAgLy8gJEZsb3dGaXhNZTogRmxvdyBkb2Vzbid0IHVuZGVyc3RhbmQgY29tcHV0ZWQgdmFsdWVzXG4gICAgICAgIGlmICghaXRlbXNba2V5XSkgcmV0dXJuIGk7XG4gICAgICAgIHJldHVybiBpdGVtc1trZXldO1xuICAgICAgfSk7XG4gICAgfVxuICAgIHJldHVybiB2YWx1ZTtcbiAgfTtcbn1cbiJdfQ==
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./lib"), exports);
__exportStar(require("./lib/types"), exports);
//# sourceMappingURL=index.js.map
{
"name": "@rimiti/stimmy",
"version": "1.9.0",
"version": "1.10.0",
"description": "Replace your string variables by your values easily.",
"license": "MIT",
"author": "Dimitri DO BAIRRO <dimitri.dobairro@dimsolution.com>",
"main": "dist/index.js",
"scripts": {
"clean": "rm -rf coverage dist tmp jest_0",
"lint": "eslint .",
"postlint": "npm run typecheck",
"typecheck": "flow check",
"pretest": "npm run lint",
"prepare": "npm run test && npm run build",
"test": "npm run test-only",
"test-only": "jest --coverage",
"test:watch": "jest --watch",
"build": "babel src -d dist --source-maps inline",
"build:watch": "babel --watch src -d dist --source-maps inline"
"types": "dist/index.d.ts",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/rimiti/stimmy.git"
},
"keywords": [
"string",
"manipulator",
"manipulation",
"variable",
"replace"
],
"author": {
"name": "Dimitri DO BAIRRO",
"email": "dimitri.dobairro@dimsolution.com",
"url": "dimsolution.com"
},
"bugs": {
"url": "https://github.com/rimiti/stimmy/issues"
},
"engines": {
"node": ">=6.9"
},
"engineStrict": true,
"homepage": "https://github.com/rimiti/stimmy#readme",
"devDependencies": {
"@babel/cli": "7.12.10",
"@babel/core": "7.12.10",
"@babel/preset-env": "7.12.11",
"@babel/preset-flow": "7.12.1",
"babel-eslint": "10.1.0",
"eslint": "7.18.0",
"eslint-config-airbnb-base": "14.2.1",
"eslint-plugin-flowtype": "5.2.0",
"eslint-plugin-import": "2.22.1",
"jest": "26.6.3",
"flow-bin": "0.143.0"
"@types/express": "4.17.13",
"@types/jest": "27.0.3",
"@types/lodash": "4.14.177",
"@types/redis": "2.8.32",
"@typescript-eslint/eslint-plugin": "5.4.0",
"@typescript-eslint/parser": "5.4.0",
"eslint": "8.3.0",
"eslint-config-prettier": "8.3.0",
"jest": "27.3.1",
"prettier": "2.4.1",
"ts-jest": "27.0.7",
"typescript": "4.5.2"
},
"jest": {
"coverageThreshold": {
"global": {
"branches": 100,
"functions": 100,
"lines": 100,
"statements": 100
}
},
"testEnvironment": "node",
"moduleFileExtensions": [
"js"
],
"coverageDirectory": "coverage",
"collectCoverageFrom": [
"src/**/*.js"
]
"scripts": {
"clean": "rm -rf dist coverage",
"build:clean": "yarn clean && yarn build",
"build": "tsc",
"build:watch": "tsc -w",
"lint": "yarn prettier && yarn eslint",
"lint:fix": "yarn prettier:fix && yarn eslint:fix",
"prettier": "prettier --check '{src,__tests__}/**/*.ts'",
"prettier:fix": "prettier --write '{src,__tests__}/**/*.ts'",
"eslint": "eslint {src,__tests__}/**/*.ts",
"eslint:fix": "eslint --fix {src,__tests__}/**/*.ts",
"test": "jest",
"test:watch": "jest --watch"
}
}
# stimmy
[![Dependencies][prod-dependencies-badge]][prod-dependencies]
[![Code Climate score][codeclimate-score-badge]][codeclimate-score]
[![Codecov][coverage-badge]][coverage]
[![Code Climate issue][codeclimate-issues-badge]][codeclimate-issues]
[![Build Status][travis-badge]][travis-ci]
[![MIT License][license-badge]][LICENSE]
[![Build][build-badge]][build]
[![License][license-badge]][license]
[![PRs Welcome][prs-badge]][prs]

@@ -19,3 +15,3 @@

```bash
$ npm install @rimiti/stimmy --save
$ yarn add @rimiti/stimmy
```

@@ -39,3 +35,3 @@

```javascript
import stimmy from '@rimiti/stimmy';
import { stimmy } from '@rimiti/stimmy';
```

@@ -45,3 +41,3 @@

```javascript
const stimmy = require('@rimiti/stimmy');
const { stimmy } = require('@rimiti/stimmy');
```

@@ -87,12 +83,11 @@ **init pattern**

Run using npm run <script> command.
Run using yarn 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.
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.

@@ -103,15 +98,7 @@

[prod-dependencies-badge]: https://david-dm.org/rimiti/stimmy/status.svg
[prod-dependencies]: https://david-dm.org/rimiti/stimmy
[codeclimate-score-badge]: https://api.codeclimate.com/v1/badges/4d4c1ba660e878509721/maintainability
[codeclimate-score]: https://codeclimate.com/github/rimiti/stimmy/maintainability
[coverage-badge]: https://codecov.io/gh/rimiti/stimmy/branch/master/graph/badge.svg
[coverage]: https://codecov.io/gh/rimiti/stimmy
[codeclimate-issues-badge]: https://codeclimate.com/github/rimiti/stimmy/badges/issue_count.svg
[codeclimate-issues]: https://codeclimate.com/github/rimiti/stimmy
[travis-badge]: https://travis-ci.org/rimiti/stimmy.svg?branch=master
[travis-ci]: https://travis-ci.org/rimiti/stimmy
[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
[prs]: http://makeapullrequest.com
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc