import infoDict from './dict/info-dict.json' ; import { AllArgs } from 'cnchar-types/main' ; import { Json } from 'cnchar-types/main/common' ; import { IHas , IFunc , IMapJson } from 'cnchar-types/main/tool' ; export const mapJson = ( key , value , cb ) : void => { if ( typeof key === 'object' ) { for ( const k in key ) { cb ( k , key [ k ] ) ; } return ; } cb ( key , value ) ; } ; export const isCnChar = ( word ) : boolean => { const unicode = word . charCodeAt ( 0 ) ; return unicode >= 19968 && unicode <= 40869 ; } ; export const has = ( args , name ) : boolean => { return args . indexOf ( name ) !== - 1 ; } ; export function isPolyWord ( word ) { if ( word === '' ) { return false ; } if ( word . length > 1 ) { word = word [ 0 ] ; } if ( ! isCnChar ( word ) ) { return false ; } return infoDict . polyWord . indexOf ( word ) !== - 1 ; } export const _throw = ( err ) : never => { throw new Error ( 'CnChar Error:' + err ) ; } ; export const _warn = ( info ) : void => { console . warn ( 'CnChar Warning:' + info ) ; } ;