Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cn-number

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cn-number - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

4

dist/index.js

@@ -1,4 +0,4 @@

var C=new Map([[-2,"\u4E24"],[-1,"\u8D1F"],[0,"\u96F6"],[1,"\u4E00"],[2,"\u4E8C"],[3,"\u4E09"],[4,"\u56DB"],[5,"\u4E94"],[6,"\u516D"],[7,"\u4E03"],[8,"\u516B"],[9,"\u4E5D"],[10,"\u5341"],[100,"\u767E"],[1000,"\u5343"],[1e4,"\u4E07"],[1e8,"\u4EBF"]]),m=new Map([[-2,"\u5169"],[-1,"\u8CA0"],[0,"\u96F6"],[1,"\u4E00"],[2,"\u4E8C"],[3,"\u4E09"],[4,"\u56DB"],[5,"\u4E94"],[6,"\u516D"],[7,"\u4E03"],[8,"\u516B"],[9,"\u4E5D"],[10,"\u5341"],[100,"\u767E"],[1000,"\u5343"],[1e4,"\u842C"],[1e8,"\u5104"]]),c=new Map([[-2,"\u8D30"],[-1,"\u8D1F"],[0,"\u96F6"],[1,"\u58F9"],[2,"\u8D30"],[3,"\u53C1"],[4,"\u8086"],[5,"\u4F0D"],[6,"\u9646"],[7,"\u67D2"],[8,"\u634C"],[9,"\u7396"],[10,"\u62FE"],[100,"\u4F70"],[1000,"\u4EDF"],[1e4,"\u4E07"],[1e8,"\u4EBF"]]),f=new Map([[-2,"\u8CB3"],[-1,"\u8CA0"],[0,"\u96F6"],[1,"\u58F9"],[2,"\u8CB3"],[3,"\u53C3"],[4,"\u8086"],[5,"\u4F0D"],[6,"\u9678"],[7,"\u67D2"],[8,"\u634C"],[9,"\u7396"],[10,"\u62FE"],[100,"\u4F70"],[1000,"\u4EDF"],[1e4,"\u842C"],[1e8,"\u5104"]]),N=new Map([[0,"\u3007"],[1,"\u4E00"],[2,"\u4E8C"],[3,"\u4E09"],[4,"\u56DB"],[5,"\u4E94"],[6,"\u516D"],[7,"\u4E03"],[8,"\u516B"],[9,"\u4E5D"]]);function x(n){const e=n?.capital??l.capital;return{dict:n?.traditional??l.traditional?e?f:m:e?c:C,liang:n?.liang??l.liang}}function O(n){const e=n?.capital??l.capital;return n?.traditional??l.traditional?e?f:m:e?c:N}var D;((i)=>{i[i.No=0]="No";i[i.Bai=4]="Bai";i[i.Qian=8]="Qian";i[i.Wan=16]="Wan";i[i.Yi=256]="Yi";i[i.QianWanYi=280]="QianWanYi";i[i.BaiQianWanYi=284]="BaiQianWanYi"})(D||={});var l={traditional:!1,capital:!1,liang:280};function p(n){const e=[];for(let t=n;t;t=Math.floor(t/10))e.push(t%10);return e}function M(n){if(!Number.isInteger(n))throw new TypeError("`n` must be an integer");if(!n)return{neg:!1,digits:[0]};const e=n<0;return{neg:e,digits:p(e?-n:n)}}function w(n,e,t,o){n.push(t.get(e===2?o&4?-2:2:e),t.get(100))}function T(n,e,t,o){n.push(t.get(e===2?o&8?-2:2:e),t.get(1000))}function y(n,e,t,o){n.push(t.get(e===2?o&16?-2:2:e))}function F(n,e,t,o){n.push(t.get(e===2?o&256?-2:2:e),t.get(1e8))}function b(n,e,t,o){const a=e.length;if(a===1)n.push(t.get(e[0]));else if(a===2){const[r,u]=e;if(u!==1)n.push(t.get(u));n.push(t.get(10)),r&&n.push(t.get(e[0]))}else if(a===3){const[r,u,i]=e;if(w(n,i,t,o),u)n.push(t.get(u),t.get(10)),r&&n.push(t.get(r));else r&&n.push(t.get(0),t.get(r))}else{const[r,u,i,s]=e;if(T(n,s,t,o),i)if(w(n,i,t,o),u)n.push(t.get(u),t.get(10)),r&&n.push(t.get(r));else r&&n.push(t.get(0),t.get(r));else if(u)n.push(t.get(0),t.get(u),t.get(10)),r&&n.push(t.get(r));else r&&n.push(t.get(0),t.get(r))}}function h(n,e){const{dict:t,liang:o}=e,{neg:a,digits:r}=M(n),u=a?[t.get(-1)]:[];return b(u,r,t,o),u.join("")}function g(n,e){const t=n<0,o=t?-n:n,a=Math.floor(o/1e4);if(!a)return h(n,e);const{dict:r,liang:u}=e,i=t?[r.get(-1)]:[];a===2?y(i,a,r,u):b(i,p(a),r,u),i.push(r.get(1e4));const s=o%1e4;if(s)s<1000?s>9&&s<20?i.push(r.get(0),r.get(1)):i.push(r.get(0)):a%100||i.push(r.get(0)),b(i,p(s),r,u);return i.join("")}function W(n,e){const t=n<0,o=t?-n:n,a=Math.floor(o/1e8);if(!a)return g(n,e);const{dict:r}=e,u=t?[r.get(-1)]:[];a===2?F(u,a,r,e.liang):u.push(g(a,e),r.get(1e8));const i=o%1e8;if(i)i<1e7?i>9&&i<20?u.push(r.get(0),r.get(1),h(i,e)):u.push(r.get(0),g(i,e)):a%100?u.push(g(i,e)):u.push(r.get(0),g(i,e));return u.join("")}function j(n){const e=n?.absLessThan??1/0,t=x(n);if(e>1e8)return function(o){return W(o,t)};return e>1e4?function(o){return g(o,t)}:function(o){return h(o,t)}}function B(n){const e=O(n);return function(t){return p(t).reverse().map((o)=>e.get(o)).join("")}}export{p as notNegToDigits,B as newCnSerialNumConvertor,j as newCnNumConvertor,M as intToDigits,D as UseLiang,N as SerialDigitCN,m as DigitTraditionalCN,f as DigitCapitalTraditionalCN,c as DigitCapitalCN,C as DigitCN};
var C=new Map([[-2,"\u4E24"],[-1,"\u8D1F"],[0,"\u96F6"],[1,"\u4E00"],[2,"\u4E8C"],[3,"\u4E09"],[4,"\u56DB"],[5,"\u4E94"],[6,"\u516D"],[7,"\u4E03"],[8,"\u516B"],[9,"\u4E5D"],[10,"\u5341"],[100,"\u767E"],[1000,"\u5343"],[1e4,"\u4E07"],[1e8,"\u4EBF"]]),m=new Map([[-2,"\u5169"],[-1,"\u8CA0"],[0,"\u96F6"],[1,"\u4E00"],[2,"\u4E8C"],[3,"\u4E09"],[4,"\u56DB"],[5,"\u4E94"],[6,"\u516D"],[7,"\u4E03"],[8,"\u516B"],[9,"\u4E5D"],[10,"\u5341"],[100,"\u767E"],[1000,"\u5343"],[1e4,"\u842C"],[1e8,"\u5104"]]),c=new Map([[-2,"\u8D30"],[-1,"\u8D1F"],[0,"\u96F6"],[1,"\u58F9"],[2,"\u8D30"],[3,"\u53C1"],[4,"\u8086"],[5,"\u4F0D"],[6,"\u9646"],[7,"\u67D2"],[8,"\u634C"],[9,"\u7396"],[10,"\u62FE"],[100,"\u4F70"],[1000,"\u4EDF"],[1e4,"\u4E07"],[1e8,"\u4EBF"]]),f=new Map([[-2,"\u8CB3"],[-1,"\u8CA0"],[0,"\u96F6"],[1,"\u58F9"],[2,"\u8CB3"],[3,"\u53C3"],[4,"\u8086"],[5,"\u4F0D"],[6,"\u9678"],[7,"\u67D2"],[8,"\u634C"],[9,"\u7396"],[10,"\u62FE"],[100,"\u4F70"],[1000,"\u4EDF"],[1e4,"\u842C"],[1e8,"\u5104"]]),N=new Map([[0,"\u3007"],[1,"\u4E00"],[2,"\u4E8C"],[3,"\u4E09"],[4,"\u56DB"],[5,"\u4E94"],[6,"\u516D"],[7,"\u4E03"],[8,"\u516B"],[9,"\u4E5D"]]);function x(n){const e=n?.capital??l.capital;return{dict:n?.traditional??l.traditional?e?f:m:e?c:C,liang:n?.liang??l.liang}}function O(n){const e=n?.capital??l.capital;return n?.traditional??l.traditional?e?f:m:e?c:N}var D;((i)=>{i[i.No=0]="No";i[i.Bai=4]="Bai";i[i.Qian=8]="Qian";i[i.Wan=16]="Wan";i[i.Yi=256]="Yi";i[i.QianWanYi=280]="QianWanYi";i[i.BaiQianWanYi=284]="BaiQianWanYi"})(D||={});var l={traditional:!1,capital:!1,liang:280};function p(n){const e=[];for(let t=n;t;t=Math.floor(t/10))e.push(t%10);return e}function M(n){if(!Number.isInteger(n))throw new TypeError("`n` must be an integer");if(!n)return{neg:!1,digits:[0]};const e=n<0;return{neg:e,digits:p(e?-n:n)}}function w(n,e,t,o){n.push(t.get(e===2?o&4?-2:2:e),t.get(100))}function T(n,e,t,o){n.push(t.get(e===2?o&8?-2:2:e),t.get(1000))}function y(n,e,t,o){n.push(t.get(e===2?o&16?-2:2:e))}function F(n,e,t,o){n.push(t.get(e===2?o&256?-2:2:e),t.get(1e8))}function b(n,e,t,o){const a=e.length;if(a===1)n.push(t.get(e[0]));else if(a===2){const{0:r,1:u}=e;if(u!==1)n.push(t.get(u));n.push(t.get(10)),r&&n.push(t.get(r))}else if(a===3){const{0:r,1:u,2:i}=e;if(w(n,i,t,o),u)n.push(t.get(u),t.get(10)),r&&n.push(t.get(r));else r&&n.push(t.get(0),t.get(r))}else{const{0:r,1:u,2:i,3:s}=e;if(T(n,s,t,o),i)if(w(n,i,t,o),u)n.push(t.get(u),t.get(10)),r&&n.push(t.get(r));else r&&n.push(t.get(0),t.get(r));else if(u)n.push(t.get(0),t.get(u),t.get(10)),r&&n.push(t.get(r));else r&&n.push(t.get(0),t.get(r))}}function h(n,e){const{dict:t,liang:o}=e,{neg:a,digits:r}=M(n),u=a?[t.get(-1)]:[];return b(u,r,t,o),u.join("")}function g(n,e){const t=n<0,o=t?-n:n,a=Math.floor(o/1e4);if(!a)return h(n,e);const{dict:r,liang:u}=e,i=t?[r.get(-1)]:[];a===2?y(i,a,r,u):b(i,p(a),r,u),i.push(r.get(1e4));const s=o%1e4;if(s)s<1000?s>9&&s<20?i.push(r.get(0),r.get(1)):i.push(r.get(0)):a%100||i.push(r.get(0)),b(i,p(s),r,u);return i.join("")}function W(n,e){const t=n<0,o=t?-n:n,a=Math.floor(o/1e8);if(!a)return g(n,e);const{dict:r}=e,u=t?[r.get(-1)]:[];a===2?F(u,a,r,e.liang):u.push(g(a,e),r.get(1e8));const i=o%1e8;if(i)i<1e7?i>9&&i<20?u.push(r.get(0),r.get(1),h(i,e)):u.push(r.get(0),g(i,e)):a%100?u.push(g(i,e)):u.push(r.get(0),g(i,e));return u.join("")}function j(n){const e=n?.absLessThan??1/0,t=x(n);if(e>1e8)return function(o){return W(o,t)};return e>1e4?function(o){return g(o,t)}:function(o){return h(o,t)}}function B(n){const e=O(n);return function(t){return p(t).reverse().map((o)=>e.get(o)).join("")}}export{p as notNegToDigits,B as newCnSerialNumConvertor,j as newCnNumConvertor,M as intToDigits,D as UseLiang,N as SerialDigitCN,m as DigitTraditionalCN,f as DigitCapitalTraditionalCN,c as DigitCapitalCN,C as DigitCN};
//# debugId=C89FA1EDA777111864756E2164756E21
//# debugId=02C3991110D3808B64756E2164756E21
//# sourceMappingURL=index.js.map
{
"name": "cn-number",
"version": "1.0.0",
"version": "1.0.1",
"author": "Wzh <wzh@uvwee.com>",

@@ -5,0 +5,0 @@ "repository": {

@@ -42,8 +42,8 @@ import type { CnNumOptFinal, CnNumOptions } from './config'

else if (len === 2) {
const [d1, d10] = digits
const { 0: d1, 1: d10 } = digits
if (d10 !== 1) parts.push(dict.get(d10)!)
parts.push(dict.get(10)!)
d1 && parts.push(dict.get(digits[0])!)
d1 && parts.push(dict.get(d1)!)
} else if (len === 3) {
const [d1, d10, d100] = digits
const { 0: d1, 1: d10, 2: d100 } = digits
bai(parts, d100, dict, liang)

@@ -55,3 +55,3 @@ if (d10) {

} else {
const [d1, d10, d100, d1000] = digits
const { 0: d1, 1: d10, 2: d100, 3: d1000 } = digits
qian(parts, d1000, dict, liang)

@@ -58,0 +58,0 @@ if (d100) {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc