Skip to content
This repository has been archived by the owner on Jun 27, 2024. It is now read-only.

This lib has some of the most used functions in every project, be it web, mobile or backend.

License

Notifications You must be signed in to change notification settings

gok-dev/js-essentials-functions

Repository files navigation

JS Essentials Functions

This lib has some of the most used functions in every project, be it web, mobile or backend.

Package Informations

npm npm GitHub issues GitHub last commit

Deep Code

deepcode

Install

if using npm:

$ npm install js-essentials-functions --save

if using yarn:

$ yarn add js-essentials-functions

Available Functions

name accept type description
cpfCnpjMask string Returns the masked CPF or CNPJ
cpfCnpjUnmask string Clears the CPF or CNPJ mask and returns a string
cepMask string Return the masked CEP
cepUnmask string Clear the CEP mask and return a string
telephoneMask string Return the masked telephone
telephoneUnmask string Clear the telephone mask and return a string
dateMask string Return the masked date in pt-br format
dateMaskUS string Return the masked date in en-us format

Usage with React

import React, { useState } from 'react'
import { cpfCnpjMask } from 'js-essentials-functions'

function App() {
  const [cpf, setCpf] = useState('')

  return (
    <form>
      <input
        name="cpf"
        type="text"
        maxLength={11}
        onChange={(e) => setCpf(e.target.value)}
        value={cpfCnpjMask(cpf)}
      />
    </form>
  )
}

Usage with React Native

import React, { useState } from 'react';
impot { View, TextInput } from 'react-native';
import { cpfCnpjMask } from 'js-essentials-functions'

function App() {
  const [cpf, setCpf] = useState('');

  return (
    <View style={{ flex: 1 }}>
      <TextInput
        onChangeText={(e) => setCpf(e)}
        value={cpfCnpjMask(cpf)}
      />
    </View>
  );
}

Contribution

Contributions are what make the open source community an incredible place to learn, inspire and create. Any contribution you make will be much appreciated.

  1. Fork the project
  2. Create a Branch for your Feature (git checkout -b feature/newFeature)
  3. Add your changes (git add .)
  4. Commit your changes (git commit -m 'Add new feature!)
  5. Push the Branch (git push origin feature/newFeature)
  6. Open a Pull Request

Contributors


Julio Augusto

Jhonatas Matos

Licença

The Apache 2.0 (APACHE 2.0)