Neutral Point Measurement

    @postalcode/postalcode
    TypeScript icon, indicating that this package has built-in type declarations

    1.1.2 • Public • Published

    Coverage Status npm version Known Vulnerabilities Workflow status badge Workflow status badge

    # PostalCode

    Package Gateway for others gateway promises

    Plugins

    PostalCode is currently extended with the following plugins. Instructions on how to use them in your own application are linked below.

    Plugin Country README
    ViaCep BR plugins/service-via-cep/README.md
    • Contribute for new plugins.

    Installation

    Browser using CDN

    <script src="https://unpkg.com/@postalcode/postalcode@latest/dist/index.min.js"></script>
    

    npm

    $ npm install --save @postalcode/postalcode
    

    yarn

    $ yarn add @postalcode/postalcode
    

    Typescript

    import { PostalCode } from "@postalcode/postalcode";
    import ViaCepService, { ServiceOptions } from "@postalcode/service-viacep";
    
    const postalCode = new PostalCode({
      /* All Postal Code Options*/
    });
    postCode.use<ServiceOptions>(ViaCepService, {
      /* All Service Options*/
    });
    
    postCode.get("05010000").then(console.log);
    
    // {
    //   "postalcode":  "05010000",
    //   "state":  "SP",
    //   "city":  "São Paulo",
    //   "street":  "Rua Caiubí",
    //   "neighborhood":  "Perdizes",
    // }

    Browser using CDN and plugins CDN

    <script src="https://unpkg.com/@postalcode/postalcode@latest/dist/index.min.js"></script>
    <script src="https://unpkg.com/@postalcode/service-viacep@latest/dist/index.min.js"></script>
    
    <script>
      const postal = new postalcode({
        /* PostalCode configs*/
      });
    
      postal.use(serviceViacep, {
        /* Service configs*/
      });
    
      //postal.use(otherService) accept multiple service
    
      postal.get("05010000").then(console.log);
    
      // {
      //   "postalcode":  "05010000",
      //   "state":  "SP",
      //   "city":  "São Paulo",
      //   "street":  "Rua Caiubí",
      //   "neighborhood":  "Perdizes",
      // }
    </script>

    PostalCode Options

    {
      //Filter plugins by country;
      //default: get all postal code in all country plugins inputted in .use()
      //ex: country:"BR" -> get postal code in "BR" country plugins inputted in .use()
      //@type: string
      country: "*",
      //Postal Code length
      //default: is 0, it captur automatic in plugins inserted in .use()
      //@type: number
      postalCodeSize:0,
      //Set All plugins timeout.
      //default: is 30s in milliseconds
      //@type: number
      timeout: 30000
    }

    how to contribute

    Read our contribution guide here

    contributors


    @weltongbi

    Install

    npm i @postalcode/postalcode

    DownloadsWeekly Downloads

    1

    Version

    1.1.2

    License

    MIT

    Unpacked Size

    52.1 kB

    Total Files

    13

    Last publish

    Collaborators

    • weltongbi