is-valid-abn
Advanced tools
Comparing version 1.2.0 to 1.3.0
var weights = [10, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]; | ||
export default function isValidABN(rawAbn) { | ||
if (!rawAbn) { | ||
return false; | ||
} // strip non-alphanumeric characters | ||
var abn = rawAbn.toString().replace(/[^a-z\d]/gi, ''); // check if length is 11 digits | ||
if (abn.length !== 11) { | ||
return false; | ||
} // apply ato check method | ||
var sum = 0; | ||
for (var position = 0; position < weights.length; position += 1) { | ||
var weight = weights[position]; | ||
var digit = parseInt(abn[position], 10) - (position ? 0 : 1); | ||
sum += weight * digit; | ||
} | ||
var checksum = sum % 89; | ||
return checksum === 0; | ||
} | ||
if (!rawAbn) { | ||
return false; | ||
} | ||
// strip non-alphanumeric characters | ||
var abn = rawAbn.toString().replace(/[^a-z\d]/gi, ''); | ||
// check if length is 11 digits | ||
if (abn.length !== 11) { | ||
return false; | ||
} | ||
// apply ato check method | ||
var sum = 0; | ||
for (var position = 0; position < weights.length; position += 1) { | ||
var weight = weights[position]; | ||
var digit = parseInt(abn[position], 10) - (position ? 0 : 1); | ||
sum += weight * digit; | ||
} | ||
var checksum = sum % 89; | ||
return checksum === 0; | ||
} |
{ | ||
"name": "is-valid-abn", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Check if a number is a valid Australian Business Number (ABN)", | ||
"main": "dist/umd/index.js", | ||
"main": "dist/cjs/index.js", | ||
"module": "dist/esm/index.js", | ||
"source": "src/index.js", | ||
"source": "src/index.ts", | ||
"types": "src/index.ts", | ||
"sideEffects": false, | ||
@@ -14,10 +15,12 @@ "type": "module", | ||
"scripts": { | ||
"build": "yarn build-esm && yarn build-umd", | ||
"build-esm": "BABEL_ENV=production-esm babel src -d dist/esm --ignore **/*.spec.js", | ||
"build-umd": "BABEL_ENV=production-umd babel src -d dist/umd --ignore **/*.spec.js", | ||
"build": "yarn build-esm && yarn build-cjs", | ||
"build-esm": "tsc --project tsconfig.build.json --outDir dist/esm --module esnext", | ||
"build-cjs": "tsc --project tsconfig.build.json --outDir dist/cjs --module commonjs", | ||
"clean": "rimraf dist", | ||
"jest": "jest", | ||
"lint": "eslint src/ --ext .jsx,.js", | ||
"lint": "eslint src --ext .js,.ts", | ||
"prepack": "yarn clean && yarn build", | ||
"test": "yarn lint && yarn jest" | ||
"prettier": "prettier --check . --cache", | ||
"test": "yarn lint && yarn tsc && yarn prettier && yarn jest", | ||
"tsc": "tsc --noEmit" | ||
}, | ||
@@ -34,12 +37,16 @@ "keywords": [ | ||
"devDependencies": { | ||
"@babel/cli": "^7.15.0", | ||
"@babel/core": "^7.15.0", | ||
"@babel/preset-env": "^7.15.0", | ||
"eslint": "^8.5.0", | ||
"eslint-config-wojtekmaj": "^0.6.5", | ||
"@babel/preset-typescript": "^7.18.6", | ||
"@types/jest": "^29.0.0", | ||
"@typescript-eslint/eslint-plugin": "^5.41.0", | ||
"@typescript-eslint/parser": "^5.44.0", | ||
"eslint": "^8.26.0", | ||
"eslint-config-wojtekmaj": "^0.7.1", | ||
"husky": "^8.0.0", | ||
"jest": "^27.0.0", | ||
"prettier": "^2.5.0", | ||
"jest": "^29.0.0", | ||
"prettier": "^2.7.0", | ||
"pretty-quick": "^3.1.0", | ||
"rimraf": "^3.0.0" | ||
"rimraf": "^3.0.0", | ||
"typescript": "^4.9.4" | ||
}, | ||
@@ -55,5 +62,6 @@ "resolutions": { | ||
"type": "git", | ||
"url": "https://github.com/DemystData/is-valid-abn.git" | ||
"url": "https://github.com/wojtekmaj/is-valid-abn.git" | ||
}, | ||
"funding": "https://github.com/wojtekmaj/is-valid-abn?sponsor=1", | ||
"packageManager": "yarn@3.1.0" | ||
} |
@@ -1,2 +0,2 @@ | ||
[](https://www.npmjs.com/package/is-valid-abn)  [](https://github.com/DemystData/is-valid-abn/actions) [](https://github.com/facebook/jest) | ||
[](https://www.npmjs.com/package/is-valid-abn)  [](https://github.com/wojtekmaj/is-valid-abn/actions) [](https://github.com/facebook/jest) | ||
@@ -15,3 +15,3 @@ # Is-Valid-ABN | ||
- [is-valid-acn](https://github.com/DemystData/is-valid-acn): Check if a number is a valid Australian Company Number (ACN). | ||
- [is-valid-acn](https://github.com/wojtekmaj/is-valid-acn): Check if a number is a valid Australian Company Number (ACN). | ||
@@ -18,0 +18,0 @@ ## Examples |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
7874
14
112
1