{"id":13789970,"url":"https://github.com/figuarnieri/maskfy","last_synced_at":"2025-08-03T03:06:58.765Z","repository":{"id":57291645,"uuid":"101226966","full_name":"figuarnieri/maskfy","owner":"figuarnieri","description":"A Javascript library without a dependencies... Compatibility with Vanilla, React and wherever. With only 1kb (gzip) code. It's also well accepted on mobile devices","archived":false,"fork":false,"pushed_at":"2025-05-21T12:47:52.000Z","size":11293,"stargazers_count":18,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-25T03:49:39.693Z","etag":null,"topics":["1kb","data-mask","input-mask","inputmask","javascript","mask","nojquery"],"latest_commit_sha":null,"homepage":"https://figuarnieri.github.io/maskfy/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/figuarnieri.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-08-23T21:35:13.000Z","updated_at":"2025-07-24T14:35:30.000Z","dependencies_parsed_at":"2025-05-17T04:25:50.228Z","dependency_job_id":"c3e7922d-06c3-4843-9879-389471e31dfc","html_url":"https://github.com/figuarnieri/maskfy","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/figuarnieri/maskfy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/figuarnieri%2Fmaskfy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/figuarnieri%2Fmaskfy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/figuarnieri%2Fmaskfy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/figuarnieri%2Fmaskfy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/figuarnieri","download_url":"https://codeload.github.com/figuarnieri/maskfy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/figuarnieri%2Fmaskfy/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268488270,"owners_count":24258244,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-03T02:00:12.545Z","response_time":2577,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["1kb","data-mask","input-mask","inputmask","javascript","mask","nojquery"],"created_at":"2024-08-03T22:00:35.366Z","updated_at":"2025-08-03T03:06:58.745Z","avatar_url":"https://github.com/figuarnieri.png","language":"HTML","funding_links":[],"categories":[":clap: 欢迎参与​"],"sub_categories":["js框架"],"readme":"# Maskfy (3.1.4) - Mask Simple\n![GitHub](https://img.shields.io/github/license/figuarnieri/maskfy?style=plastic) ![npm package minimized gzipped size](https://img.shields.io/bundlejs/size/maskfy?style=plastic) ![GitHub](https://img.shields.io/badge/CDN-jsDelivr-yellow?style=plastic) ![GitHub](https://img.shields.io/badge/AMD-purple?style=plastic) ![GitHub](https://img.shields.io/badge/CommonJS-purple?style=plastic) ![GitHub](https://img.shields.io/badge/ESModule-purple?style=plastic)\n\n![Logo](https://github.com/figuarnieri/maskfy/raw/master/assets/cover.webp)\n\nA Javascript library without a dependencies... Compatibility with Vanilla, React and wherever. With only 1kb (gzip) code. It's also well accepted on mobile devices\n\n## Install\n\n### Node modules\n\n```sh\nnpm i maskfy\n```\n\nor\n\n```sh\nyarn add maskfy\n```\n\n## Usage\n\n### React\n\n```jsx\nimport { maskfy } from 'maskfy';\nimport { useState } from 'react';\n\n...\n\nconst [stateValue, setStateValue] = useState('')\n\n...\n\nconst handleInput = (e) =\u003e {\n  const { value } = e.currentTarget;\n  const valueWithMask = maskfy(value, { mask: '(99) 9999-9999' });\n  setStateValue(valueWithMask);\n}\n\n...\n\n\u003cinput name=\"phone\" value={stateValue} onInput={handleInput} /\u003e\n```\n\n### Vue\n```sh\n// Coming soon\n```\n\n### Angular\n```sh\n// Coming soon\n```\n\n### ES Module\n```jsx\nimport { maskfy } from 'maskfy'\n\nconst valueMask = maskfy(valueInput, { mask: '(99) 9999-9999' });\nconsole.log(valueMask);\n```\n\n### CommonJS\n```js\nconst { maskfy } = require('maskfy/dist/cjs');\n\nconst valueMask = maskfy(valueInput, { mask: '(99) 9999-9999' });\nconsole.log(valueMask);\n```\n\n### AMD\n```html\n\u003cscript src=\"./dist/amd/index.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  const valueMask = window.Maskfy.maskfy(valueInput, { mask: '(99) 9999-9999' });\n  console.log(valueMask);\n\u003c/script\u003e\n```\n\n### CDN\n```html\n\u003cinput id=\"phone\" /\u003e\n\n...\n\n\u003cscript type=\"module\"\u003e\n  import { maskfy } from 'https://cdn.jsdelivr.net/gh/figuarnieri/maskfy@master/dist/esm/index.js'\n\n  document.querySelector('#phone').addEventListener('input', (e) =\u003e {\n    const valueMask = maskfy(e.target.value, { mask: '(99) 9999-9999' });\n    e.target.value = valueMask.toUpperCase();\n  });\n\u003c/script\u003e\n```\n\n## Syntax\n\n```jsx\nmaskfy(value);\nmaskfy(value, options);\n```\n\n### Parameters\n\n#### value\nString to which the mask will be applied (optional)\n\n#### options `optional`\nObject used to configure the mask\n\n| Name    | Type                      | Default             | Description                                                                  |\n| ------- | ------------------------- | ------------------- | ---------------------------------------------------------------------------- |\n| mask    | string                    | `'999.999.999.999'` | String for mask implementation                                               |\n| reverse | boolean                   | `false`             | Applies the mask with character reversal. Commonly used for price formatting |\n| keybind | { [key: String]: RegExp } | object (1)          | Object for implementing character patterns of a mask                         |\n| prefix  | string                    | `''`                | Prefix applied to the masked value                                           |\n| suffix  | string                    | `''`                | Suffix applied to the masked value                                           |\n\n```jsx\n// (1) Default keybind object\n{\n  mask: '999.999.999.999',\n  reverse: false,\n  keybind: {\n    A: /[A-Za-z]/,\n    9: /\\d/,\n    '?': /./,\n  },\n  prefix: '',\n  suffix: ''\n}\n```\n\n## Examples\n\n```jsx\n// Negative price\nmaskfy(value, {\n  mask: '999.999.999.999,99',\n  reverse: true,\n  prefix: '-',\n})\n\n// Percent number\nmaskfy(value, {\n  mask: '999',\n  suffix: '%',\n})\n\n// Employer Identification Number (Brazil)\nmaskfy(value, {\n  mask: '999.999.999/9999-99',\n})\n\n// License plate number\nmaskfy(value, {\n  mask: '9AAA999',\n})\n\n// License plate number (Mercosul)\nmaskfy(value, {\n  mask: 'AAA 9A99',\n})\n```\n\n## Coming soon\n- Support to Vue\n- Support to Angular\n- Add plugin to handle input elements with data-* attributes\n- Add formatBefore and formatAfter options\n\n### Site\nAccess [figuarnieri.github.io/maskfy](https://figuarnieri.github.io/maskfy/)\n\n## Source\n[Github](https://github.com/figuarnieri/maskfy) | [npm](https://www.npmjs.com/package/maskfy)\n\n## License\nThe MIT License\ncreated by [Filipe Guarnieri](https://figuarnieri.github.io/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffiguarnieri%2Fmaskfy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffiguarnieri%2Fmaskfy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffiguarnieri%2Fmaskfy/lists"}