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.2.4 to 0.3.0

LICENSE

2

dist/format-string-by-pattern.js

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

function e(e,r){if(!r)return"";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=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)}};
//# sourceMappingURL=format-string-by-pattern.js.map

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

function e(e,r){if(!r)return"";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=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)}};
//# 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"";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,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)}}});
//# sourceMappingURL=format-string-by-pattern.umd.js.map
{
"name": "format-string-by-pattern",
"version": "0.2.4",
"version": "0.3.0",
"description": "A module that formats a string based on a pattern",

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

@@ -5,11 +5,11 @@ # format-string-by-pattern

This module consists on a function that takes a pattern and a value and then returns this value formatted according to the pattern. It probably won't work with every pattern tho.
This module consists on a function that receives a pattern and a value and returns this value formatted according to the pattern.
## Why?
I was writing one specific function to each formatted value I had to obtain from an input and that sucks, so I decided to try write a function to format any value based on any pattern. This is my attempt. 😃
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. 😃
## Other solutions
There is probably other solutions to these problems. If you know any other solution, feel free to open a PR adding it to the README.md.
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.

@@ -35,2 +35,5 @@ ## Usage

This library is pretty useful with forms, where you need to parse the input values.
See the usage with the [react-final-form](https://github.com/final-form/react-final-form) library [here](https://codesandbox.io/s/no20p7z3l).
## API

@@ -37,0 +40,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

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