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

data-templater

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

data-templater

Data templater for JavaScript

  • 0.5.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Data Templater

This library is designed to take in data and format it based on a template. for example if you had the string 1234567890 and the template (???) ???-????, you could easying convert the data to an from (123) 456-7890. This was built because the only descent library I could find was tied to jQuery and as I use ReactJS, I don't need jQuery and want someting more generic. This is a simplier version base off of https://github.com/RobinHerbots/jquery.inputmask and has no dependencies.

Examples

You can look at the unit test for more examples

dataTemplater.compile('1234567890', '???-???-????');// => '123-456-7890'
dataTemplater.uncompile('123-456-7890', '???-???-????');// =>'1234567890'

//works on paritials
dataTemplater.compile('12345', '???-???-????');// => '123-45'
dataTemplater.uncompile('123-45', '???-???-????');// =>'12345'

//utility methods
dataTemplater.compiledIndexToUncompiledIndex(11, '(???) ???-????');// => 7
dataTemplater.uncompiledIndexToCompiledIndex(6, '(???) ???-????');// => 10

Keywords

FAQs

Package last updated on 18 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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