ntnyq / uscc-utils

:ok: Utils about unified social credit code | 统一社会信用代码工具方法.

Home Page:https://paka.dev/npm/uscc-utils

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

uscc-utils

CI NPM VERSION NPM DOWNLOADS CODECOV LICENSE

Utils about unified social credit code(统一社会信用代码工具方法).

Install

npm i uscc-utils
yarn add uscc-utils
pnpm add uscc-utils

Usage

import { parseUSCC, validateUSCC } from 'uscc-utils'

const code = '91110108551385082Q' // 小米科技有限责任公司

validateUSCC(code) // true

parseUSCC(code) // { isValid: true, category: '工商', type: '企业' }

API

validateUSCC

Check if the given code match the uscc pattern.

Type definition:

function validateUSCC(code: string): boolean

parseUSCC

Parse the given uscc.

Type definition:

interface ParseOptions {
  unknownCategory?: string
  unknownType?: string
}

interface ParseResult {
  isValid: boolean
  category: string
  type: string
}

function parseUSCC(code: string, options?: ParseOptions): ParseResult

Credits

License

MIT License © 2022-PRESENT ntnyq

About

:ok: Utils about unified social credit code | 统一社会信用代码工具方法.

https://paka.dev/npm/uscc-utils

License:MIT License


Languages

Language:TypeScript 98.9%Language:Shell 0.6%Language:JavaScript 0.6%