Skip to content

Commit

Permalink
new release
Browse files Browse the repository at this point in the history
  • Loading branch information
nikazooz committed Feb 27, 2021
1 parent 9f9c947 commit 5d63260
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 26 deletions.
39 changes: 21 additions & 18 deletions dist/formula-parser.js
Expand Up @@ -3663,16 +3663,16 @@ exports.LEN = function(text) {
return error.error;
}

if (typeof text === 'string') {
return text ? text.length : 0;
if (text === null) {
return 0;
}

if (text === null || text.length === 0) {
return 0;
if (typeof text === 'string') {
return text ? text.length : 0;
}

if (text.length) {
return text.length;
if (Array.isArray(text)) {
return error.error
}

return error.value;
Expand Down Expand Up @@ -4096,10 +4096,6 @@ exports.ISERROR = function(value) {
};

exports.ISEVEN = function(number) {
if (typeof number !== 'number' && isNaN(parseFloat(number))) {
return error.error;
}

return (Math.floor(Math.abs(number)) & 1) ? false : true;
};

Expand All @@ -4125,10 +4121,6 @@ exports.ISNUMBER = function(value) {
};

exports.ISODD = function(number) {
if (typeof number !== 'number' && isNaN(parseFloat(number))) {
return error.error;
}

return (Math.floor(Math.abs(number)) & 1) ? true : false;
};

Expand Down Expand Up @@ -4546,8 +4538,22 @@ exports.NETWORKDAYS.INTL = function (start_date, end_date, weekend, holidays) {
if (end_date instanceof Error) {
return end_date;
}

var isMask = false;
var maskDays = [];
var maskIndex = [1, 2, 3, 4, 5, 6, 0]
var maskRegex = new RegExp('^[0|1]{7}$');

if (weekend === undefined) {
weekend = WEEKEND_TYPES[1];
} else if (typeof weekend === 'string' && maskRegex.test(weekend)) {
isMask = true;
weekend = weekend.split('');
for (i = 0; i < weekend.length; i++) {
if (weekend[i] == 1) {
maskDays.push(maskIndex[i]);
}
}
} else {
weekend = WEEKEND_TYPES[weekend];
}
Expand All @@ -4572,10 +4578,7 @@ exports.NETWORKDAYS.INTL = function (start_date, end_date, weekend, holidays) {
var day = start_date;
for (i = 0; i < days; i++) {
var d = (new Date().getTimezoneOffset() > 0) ? day.getUTCDay() : day.getDay();
var dec = false;
if (d === weekend[0] || d === weekend[1]) {
dec = true;
}
var dec = isMask ? maskDays.includes(d) : (d === weekend[0] || d === weekend[1]);
for (var j = 0; j < holidays.length; j++) {
var holiday = holidays[j];
if (holiday.getDate() === day.getDate() &&
Expand Down
2 changes: 1 addition & 1 deletion dist/formula-parser.min.js

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "@startinfinity/hot-formula-parser",
"version": "5.0.6",
"version": "5.0.7",
"description": "Formula parser",
"main": "./index",
"module": "./index.mjs",
Expand Down Expand Up @@ -65,7 +65,7 @@
"webpack-cli": "^4.2.0"
},
"dependencies": {
"@formulajs/formulajs": "git+https://github.com/nikazooz/formulajs.git#fix/isevan-isodd-and-len",
"@formulajs/formulajs": "^2.6.5",
"tiny-emitter": "^2.1.0"
},
"jest": {
Expand Down
4 changes: 2 additions & 2 deletions test/integration/parsing/formula/information.js
Expand Up @@ -28,7 +28,7 @@ describe('.parse() information formulas', () => {
expect(parser.parse('ISEVEN(1)')).toMatchObject({error: null, result: false});
expect(parser.parse('ISEVEN(2)')).toMatchObject({error: null, result: true});
expect(parser.parse('ISEVEN(2.5)')).toMatchObject({error: null, result: true});
expect(parser.parse('ISEVEN("A")')).toMatchObject({error: '#ERROR!', result: null});
expect(parser.parse('ISEVEN(NULL)')).toMatchObject({error: null, result: true});
});

it('ISLOGICAL', () => {
Expand Down Expand Up @@ -59,7 +59,7 @@ describe('.parse() information formulas', () => {
expect(parser.parse('ISODD(1)')).toMatchObject({error: null, result: true});
expect(parser.parse('ISODD(2)')).toMatchObject({error: null, result: false});
expect(parser.parse('ISODD(2.5)')).toMatchObject({error: null, result: false});
expect(parser.parse('ISODD("A")')).toMatchObject({ error: '#ERROR!', result: null });
expect(parser.parse('ISODD(NULL)')).toMatchObject({error: null, result: false});
});

it('ISTEXT', () => {
Expand Down

0 comments on commit 5d63260

Please sign in to comment.