replace-element
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

replace-element

npm version minzipped size

Finds text that matches a regular expression in the browser. Allows content to be changed with a callback function.

Installation

Download node at nodejs.org and install it, if you haven't already.

npm install replace-element --save

This package is provided in these module formats:

  • CommonJS

TL-DR

const { replaceElement } = require('../dist/index');
const { cpf, cnpj } = require('cpf-cnpj-validator');

const CpfCnpjRegex = /(\d{3}\.\d{3}\.\d{3}\-\d{2})|(\d{2}\.\d{3}\.\d{3}\/\d{4}\-\d{2})/g;
replaceElement(CpfCnpjRegex, (payload, element) => {
    /* callback */
    element.style.color = "red";
    element.style.fontWeight = "bold";
    element.onclick = function () { alert(payload); }
}, (payload) => cpf.isValid(payload) || cnpj.isValid(payload));

Dependencies

None

Dev Dependencies

  • typescript: TypeScript is a language for application scale JavaScript development

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i replace-element

Weekly Downloads

1

Version

1.1.0

License

MIT

Unpacked Size

12.2 kB

Total Files

10

Last publish

Collaborators

  • lfamorim