uscc-utils
TypeScript icon, indicating that this package has built-in type declarations

0.5.0 • Public • Published

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

Package Sidebar

Install

npm i uscc-utils

Weekly Downloads

1

Version

0.5.0

License

MIT

Unpacked Size

18.7 kB

Total Files

9

Last publish

Collaborators

  • ntnyq