New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@opendevtools/rescript-telefonnummer

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opendevtools/rescript-telefonnummer - npm Package Compare versions

Comparing version 2.1.2 to 3.0.0

.github/dependabot.yml

4

__tests__/Telefonnummer_test.bs.js

@@ -1,5 +0,5 @@

// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE
// Generated by ReScript, PLEASE EDIT WITH CARE
'use strict';
var Jest = require("@glennsl/bs-jest/src/jest.js");
var Jest = require("@glennsl/bs-jest/src/jest.bs.js");
var Telefonnummer = require("../src/Telefonnummer.bs.js");

@@ -6,0 +6,0 @@

@@ -0,1 +1,14 @@

# [3.0.0](https://github.com/opendevtools/rescript-telefonnummer/compare/v2.1.2...v3.0.0) (2021-05-20)
### Features
* include phone number in type of number ([64cc0d8](https://github.com/opendevtools/rescript-telefonnummer/commit/64cc0d8a9136a3e5f3a080c2ef5fab0ba6f3eccf))
### BREAKING CHANGES
* Type `t` has changed to include phone number
for mobile and landline numbers
## [2.1.2](https://github.com/opendevtools/rescript-telefonnummer/compare/v2.1.1...v2.1.2) (2021-01-25)

@@ -2,0 +15,0 @@

{
"name": "@opendevtools/rescript-telefonnummer",
"version": "2.1.2",
"version": "3.0.0",
"description": "Phone number formatter for Swedish phone numbers",
"author": "Rickard Natt och Dag <rickard@hey.com> (http://willcodefor.beer/)",
"publishConfig": {

@@ -8,6 +10,6 @@ "access": "public"

"scripts": {
"build": "bsb -make-world",
"start": "BS_WATCH_CLEAR=true bsb -make-world -w",
"clean": "bsb -clean-world",
"test": "is-ci \"test:ci\" \"test:watch\"",
"build": "rescript build",
"start": "BS_WATCH_CLEAR=true rescript build -w",
"clean": "rescript clean -with-deps",
"test": "is-ci-cli test:ci test:watch",
"test:ci": "jest",

@@ -17,14 +19,12 @@ "test:watch": "jest --watch"

"keywords": [
"BuckleScript",
"ReasonML",
"Phone number",
"Telefonnummer",
"Parser"
"bucklescript",
"rescript",
"phone number",
"telefonnummer"
],
"author": "believer <nattochdag@hey.com>",
"license": "MIT",
"devDependencies": {
"@glennsl/bs-jest": "0.5.1",
"bs-platform": "8.2.0",
"is-ci-cli": "2.1.2"
"@glennsl/bs-jest": "0.7.0",
"is-ci-cli": "2.2.0",
"rescript": "9.1.2"
},

@@ -31,0 +31,0 @@ "bugs": {

@@ -1,2 +0,2 @@

// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE
// Generated by ReScript, PLEASE EDIT WITH CARE
'use strict';

@@ -3,0 +3,0 @@

@@ -1,5 +0,5 @@

// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE
// Generated by ReScript, PLEASE EDIT WITH CARE
'use strict';
var Curry = require("bs-platform/lib/js/curry.js");
var Curry = require("rescript/lib/js/curry.js");
var Riktnummer = require("./Riktnummer.bs.js");

@@ -36,43 +36,55 @@

function replacer(regex, replaceWithOpt, param) {
function replacer(regex, replaceWithOpt, param, __x) {
var replaceWith = replaceWithOpt !== undefined ? replaceWithOpt : "$1-$2 $3 $4";
return function (param) {
return param.replace(regex, replaceWith);
};
return __x.replace(regex, replaceWith);
}
function fiveDigit(areaCode) {
return new RegExp("^(\\d{" + String(areaCode) + "})(\\d{3})(\\d{2})$");
}
var regex = /^08/;
function sixDigit(areaCode) {
return new RegExp("^(\\d{" + String(areaCode) + "})(\\d{2})(\\d{2})(\\d{2})$");
var partial_arg = /^(\d{2})(\d{2})(\d{2})(\d{2})$/;
function sixDigit(param) {
return replacer(partial_arg, undefined, undefined, param);
}
function sevenDigit(areaCode) {
return new RegExp("^(\\d{" + String(areaCode) + "})(\\d{3})(\\d{2})(\\d{2})$");
var partial_arg$1 = /^(\d{2})(\d{3})(\d{2})(\d{2})$/;
function sevenDigit(param) {
return replacer(partial_arg$1, undefined, undefined, param);
}
function eightDigit(areaCode) {
return new RegExp("^(\\d{" + String(areaCode) + "})(\\d{3})(\\d{3})(\\d{2})$");
var partial_arg$2 = /^(\d{2})(\d{3})(\d{3})(\d{2})$/;
function eightDigit(param) {
return replacer(partial_arg$2, undefined, undefined, param);
}
var regex = /^08/;
var regex$1 = /^0(1[013689]|2[0136]|3[1356]|4[0246]|54|6[03]|7[0235-9]|9[09])/;
var sixDigit$1 = replacer(sixDigit(2), undefined, undefined);
var partial_arg$3 = "$1-$2 $3";
var sevenDigit$1 = replacer(sevenDigit(2), undefined, undefined);
var partial_arg$4 = /^(\d{3})(\d{3})(\d{2})$/;
var eightDigit$1 = replacer(eightDigit(2), undefined, undefined);
function fiveDigit(param) {
return replacer(partial_arg$4, partial_arg$3, undefined, param);
}
var regex$1 = /^0(1[013689]|2[0136]|3[1356]|4[0246]|54|6[03]|7[0235-9]|9[09])/;
var partial_arg$5 = /^(\d{3})(\d{2})(\d{2})(\d{2})$/;
var fiveDigit$1 = replacer(fiveDigit(3), "$1-$2 $3", undefined);
function sixDigit$1(param) {
return replacer(partial_arg$5, undefined, undefined, param);
}
var sixDigit$2 = replacer(sixDigit(3), undefined, undefined);
var partial_arg$6 = /^(\d{3})(\d{3})(\d{2})(\d{2})$/;
var sevenDigit$2 = replacer(sevenDigit(3), undefined, undefined);
function sevenDigit$1(param) {
return replacer(partial_arg$6, undefined, undefined, param);
}
var sixDigit$3 = replacer(sixDigit(4), undefined, undefined);
var partial_arg$7 = /^(\d{4})(\d{2})(\d{2})(\d{2})$/;
function sixDigit$2(param) {
return replacer(partial_arg$7, undefined, undefined, param);
}
function digits(value) {

@@ -113,8 +125,14 @@ if (regex.test(value)) {

function typeOfNumber(number) {
if (number.normalize().startsWith("07")) {
return /* Mobile */1;
} else if (phoneNumbers.includes(number)) {
if (phoneNumbers.includes(number)) {
return /* VoiceMail */0;
} else if (number.normalize().startsWith("07")) {
return {
TAG: /* Mobile */0,
_0: clean(number)
};
} else {
return /* Landline */2;
return {
TAG: /* Landline */1,
_0: clean(number)
};
}

@@ -124,54 +142,52 @@ }

function parse(phoneNumber) {
var match = typeOfNumber(phoneNumber);
switch (match) {
case /* VoiceMail */0 :
return "Röstbrevlåda";
case /* Mobile */1 :
return Curry._1(sevenDigit$2, clean(phoneNumber));
case /* Landline */2 :
var pn = clean(phoneNumber);
var match$1 = digits(pn);
var match$2 = pn.length;
var tmp;
var exit = 0;
if (match$1 === "Two") {
switch (match$2) {
case 8 :
tmp = sixDigit$1;
break;
case 9 :
tmp = sevenDigit$1;
break;
case 10 :
tmp = eightDigit$1;
break;
default:
exit = 1;
}
} else if (match$1 === "Three") {
switch (match$2) {
case 8 :
tmp = fiveDigit$1;
break;
case 9 :
tmp = sixDigit$2;
break;
case 10 :
tmp = sevenDigit$2;
break;
default:
exit = 1;
}
} else if (match$1 === "Four") {
tmp = sixDigit$3;
} else {
var pn = typeOfNumber(phoneNumber);
if (typeof pn === "number") {
return "Röstbrevlåda";
} else if (pn.TAG === /* Mobile */0) {
return Curry._1(sevenDigit$1, pn._0);
} else {
var pn$1 = pn._0;
var match = digits(pn$1);
var match$1 = pn$1.length;
var tmp;
var exit = 0;
if (match === "Two") {
switch (match$1) {
case 8 :
tmp = sixDigit;
break;
case 9 :
tmp = sevenDigit;
break;
case 10 :
tmp = eightDigit;
break;
default:
exit = 1;
}
if (exit === 1) {
tmp = (function (param) {
return pn;
});
}
return tmp(pn);
}
} else if (match === "Three") {
switch (match$1) {
case 8 :
tmp = fiveDigit;
break;
case 9 :
tmp = sixDigit$1;
break;
case 10 :
tmp = sevenDigit$1;
break;
default:
exit = 1;
}
} else if (match === "Four") {
tmp = sixDigit$2;
} else {
exit = 1;
}
if (exit === 1) {
tmp = (function (param) {
return pn$1;
});
}
return tmp(pn$1);
}

@@ -184,20 +200,18 @@ }

}
var normalized = clean(phoneNumber);
var digits$1 = digits(normalized);
var typeOfNumber$1 = typeOfNumber(normalized);
switch (typeOfNumber$1) {
case /* VoiceMail */0 :
return true;
case /* Mobile */1 :
return valid.test(normalized);
case /* Landline */2 :
if (digits$1 === "Three") {
return validThreeDigit.test(normalized);
} else if (digits$1 === "Four") {
return validFourDigit.test(normalized);
} else {
return validTwoDigit.test(normalized);
}
var pn = typeOfNumber(phoneNumber);
if (typeof pn === "number") {
return true;
}
if (pn.TAG === /* Mobile */0) {
return valid.test(pn._0);
}
var pn$1 = pn._0;
var digits$1 = digits(pn$1);
if (digits$1 === "Three") {
return validThreeDigit.test(pn$1);
} else if (digits$1 === "Four") {
return validFourDigit.test(pn$1);
} else {
return validTwoDigit.test(pn$1);
}
}

@@ -214,2 +228,2 @@

exports.parse = parse;
/* sixDigit Not a pure module */
/* validThreeDigit Not a pure module */

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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