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

format-string-by-pattern

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

format-string-by-pattern - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

2

dist/format-string-by-pattern.js

@@ -1,2 +0,2 @@

function e(e,r){if(!r)return r;var t=String(r).replace(/[^\da-zA-Z\n|]/g,""),l=e.split(/[^\da-zA-Z\n|]/g).filter(Boolean).map(function(e){return e.length}),n=e.split(/[\da-zA-Z\n|]/g).filter(Boolean);return e.startsWith(n[0])?n.reduce(function(e,r,t){var n=l[t],u=e.value.slice(0,n),a=e.value.slice(n);return{result:u?e.result.concat(r,u):e.result,value:a}},{result:"",value:t}).result.slice(0,e.length):l.reduce(function(e,r,t){var l=n[t]||"",u="$1"+l+"$2",a=r+e.prevSlice+e.prevSeparator.length,i=new RegExp("(.{"+a+"})(.)");return{prevSeparator:l,prevSlice:a,value:e.value.replace(i,u)}},{prevSeparator:"",prevSlice:0,value:t}).value.slice(0,e.length)}module.exports=function(r,t){return t?e(r,t):function(t){return e(r,t)}};
function e(e,r){if(!r)return r;var t,l,n,u,a,i,c,o,p=String(r).replace(/[^\da-zA-Z\n|]/g,""),v=e.split(/[^\da-zA-Z\n|]/g).filter(Boolean).map(function(e){return e.length}),s=e.split(/[\da-zA-Z\n|]/g).filter(Boolean);return e.startsWith(s[0])?s.reduce(function(e,r,u){return l=e.value.slice(0,t=v[u]),n=e.value.slice(t),{result:l?e.result.concat(r,l):e.result,value:n}},{result:"",value:p}).result.slice(0,e.length):v.reduce(function(e,r,t){return a="$1"+(u=s[t]||"")+"$2",i=r+e.prevSlice+e.prevSeparator.length,c=new RegExp("(.{"+i+"})(.)"),o=e.value.replace(c,a),{prevSeparator:u,prevSlice:i,value:o}},{prevSeparator:"",prevSlice:0,value:p}).value.slice(0,e.length)}module.exports=function(r,t){return t?e(r,t):function(t){return e(r,t)}};
//# sourceMappingURL=format-string-by-pattern.js.map

@@ -1,2 +0,2 @@

function e(e,r){if(!r)return r;var t=String(r).replace(/[^\da-zA-Z\n|]/g,""),l=e.split(/[^\da-zA-Z\n|]/g).filter(Boolean).map(function(e){return e.length}),n=e.split(/[\da-zA-Z\n|]/g).filter(Boolean);return e.startsWith(n[0])?n.reduce(function(e,r,t){var n=l[t],u=e.value.slice(0,n),a=e.value.slice(n);return{result:u?e.result.concat(r,u):e.result,value:a}},{result:"",value:t}).result.slice(0,e.length):l.reduce(function(e,r,t){var l=n[t]||"",u="$1"+l+"$2",a=r+e.prevSlice+e.prevSeparator.length,i=new RegExp("(.{"+a+"})(.)");return{prevSeparator:l,prevSlice:a,value:e.value.replace(i,u)}},{prevSeparator:"",prevSlice:0,value:t}).value.slice(0,e.length)}module.exports=function(r,t){return t?e(r,t):function(t){return e(r,t)}};
function e(e,r){if(!r)return r;var t,l,n,u,a,i,c,o,p=String(r).replace(/[^\da-zA-Z\n|]/g,""),v=e.split(/[^\da-zA-Z\n|]/g).filter(Boolean).map(function(e){return e.length}),s=e.split(/[\da-zA-Z\n|]/g).filter(Boolean);return e.startsWith(s[0])?s.reduce(function(e,r,u){return l=e.value.slice(0,t=v[u]),n=e.value.slice(t),{result:l?e.result.concat(r,l):e.result,value:n}},{result:"",value:p}).result.slice(0,e.length):v.reduce(function(e,r,t){return a="$1"+(u=s[t]||"")+"$2",i=r+e.prevSlice+e.prevSeparator.length,c=new RegExp("(.{"+i+"})(.)"),o=e.value.replace(c,a),{prevSeparator:u,prevSlice:i,value:o}},{prevSeparator:"",prevSlice:0,value:p}).value.slice(0,e.length)}module.exports=function(r,t){return t?e(r,t):function(t){return e(r,t)}};
//# sourceMappingURL=format-string-by-pattern.m.js.map

@@ -1,2 +0,2 @@

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r():"function"==typeof define&&define.amd?define(r):r()}(0,function(){function e(e,r){if(!r)return r;var t=String(r).replace(/[^\da-zA-Z\n|]/g,""),n=e.split(/[^\da-zA-Z\n|]/g).filter(Boolean).map(function(e){return e.length}),l=e.split(/[\da-zA-Z\n|]/g).filter(Boolean);return e.startsWith(l[0])?l.reduce(function(e,r,t){var l=n[t],u=e.value.slice(0,l),a=e.value.slice(l);return{result:u?e.result.concat(r,u):e.result,value:a}},{result:"",value:t}).result.slice(0,e.length):n.reduce(function(e,r,t){var n=l[t]||"",u="$1"+n+"$2",a=r+e.prevSlice+e.prevSeparator.length,i=new RegExp("(.{"+a+"})(.)");return{prevSeparator:n,prevSlice:a,value:e.value.replace(i,u)}},{prevSeparator:"",prevSlice:0,value:t}).value.slice(0,e.length)}module.exports=function(r,t){return t?e(r,t):function(t){return e(r,t)}}});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(0,function(){function e(e,t){if(!t)return t;var n,r,l,u,i,a,o,c,p=String(t).replace(/[^\da-zA-Z\n|]/g,""),f=e.split(/[^\da-zA-Z\n|]/g).filter(Boolean).map(function(e){return e.length}),s=e.split(/[\da-zA-Z\n|]/g).filter(Boolean);return e.startsWith(s[0])?s.reduce(function(e,t,u){return r=e.value.slice(0,n=f[u]),l=e.value.slice(n),{result:r?e.result.concat(t,r):e.result,value:l}},{result:"",value:p}).result.slice(0,e.length):f.reduce(function(e,t,n){return i="$1"+(u=s[n]||"")+"$2",a=t+e.prevSlice+e.prevSeparator.length,o=new RegExp("(.{"+a+"})(.)"),c=e.value.replace(o,i),{prevSeparator:u,prevSlice:a,value:c}},{prevSeparator:"",prevSlice:0,value:p}).value.slice(0,e.length)}module.exports=function(t,n){return n?e(t,n):function(n){return e(t,n)}}});
//# sourceMappingURL=format-string-by-pattern.umd.js.map
{
"name": "format-string-by-pattern",
"version": "0.3.0",
"version": "0.3.1",
"description": "A module that formats a string based on a pattern",

@@ -5,0 +5,0 @@ "main": "dist/format-string-by-pattern.js",

@@ -1,15 +0,32 @@

# format-string-by-pattern
<h1 align="center">
format-string-by-pattern
</h1>
<p align="center">
<a href="https://www.npmjs.org/package/format-string-by-pattern"><img src="https://img.shields.io/npm/v/format-string-by-pattern.svg?style=flat" alt="npm"></a>
<a href="https://david-dm.org/arthurdenner/format-string-by-pattern"><img src="https://david-dm.org/arthurdenner/format-string-by-pattern/status.svg" alt="dependencies Status"></a>
<a href="https://unpkg.com/format-string-by-pattern/dist/format-string-by-pattern.umd.js"><img src="http://img.badgesize.io/https://unpkg.com/format-string-by-pattern/dist/format-string-by-pattern.umd.js?compression=gzip" alt="gzip size"></a>
<a href="https://packagephobia.now.sh/result?p=format-string-by-pattern"><img src="https://packagephobia.now.sh/badge?p=format-string-by-pattern" alt="install size"></a>
</p>
## Overview
This module consists on a function that receives a pattern and a value and returns this value formatted according to the pattern.
This module consists on a function that receives a pattern and a value and returns this value formatted according to the pattern. It doesn't work with every pattern, but it works with a lot of use cases.
## Why?
## Install
I had to write a specific function to format every value I needed and that sucks, so I decided to try write a function to format any value based on any pattern. This is my attempt. 😃
```
yarn add format-string-by-pattern
```
## Other solutions
```
npm i format-string-by-pattern
```
I don't know any other solutions to this problem. If you do, feel free to open a PR adding it to the README.md.
### UMD
```
<script src="https://unpkg.com/format-string-by-pattern/dist/format-string-by-pattern.umd.js"></script>
```
## Usage

@@ -16,0 +33,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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