@ukon1990/js-utilities
Advanced tools
Comparing version 1.6.1 to 1.6.2
@@ -130,3 +130,6 @@ import { EmptyUtil } from './empty.util'; | ||
for (let i = 0, length = array.length; i < length; i++) { | ||
const index = Math.round(Math.random() * tmp.length); | ||
let index = Math.round(Math.random() * tmp.length - 1); | ||
if (index < 0) { | ||
index = 0; | ||
} | ||
random.push(tmp[index]); | ||
@@ -133,0 +136,0 @@ ArrayUtil.removeIndexes([index], tmp); |
@@ -145,11 +145,22 @@ import { ArrayUtil } from './array.util'; | ||
}); | ||
it('randomOrder', () => { | ||
const list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; | ||
const list1 = ArrayUtil.randomOrder(list); | ||
const list2 = ArrayUtil.randomOrder(list); | ||
expect(list1.length).toBe(list.length); | ||
expect(list2.length).toBe(list.length); | ||
expect(ArrayUtil.isEqual(list1, list2)).toBeFalsy(); | ||
describe('randomOrder', () => { | ||
it('the list has the same length and unequal', () => { | ||
const list = [...Array(100).keys()]; | ||
const list1 = ArrayUtil.randomOrder(list); | ||
const list2 = ArrayUtil.randomOrder(list); | ||
expect(list1.length).toBe(list.length); | ||
expect(list2.length).toBe(list.length); | ||
expect(ArrayUtil.isEqual(list1, list2)).toBeFalsy(); | ||
}); | ||
it('does not contain undefined values', () => { | ||
const list = [...Array(10000).keys()]; | ||
expect(ArrayUtil.randomOrder(list) | ||
.filter(n => n === undefined).length) | ||
.toBe(0); | ||
expect(ArrayUtil.randomOrder(list) | ||
.filter(n => n === undefined).length) | ||
.toBe(0); | ||
}); | ||
}); | ||
}); | ||
//# sourceMappingURL=array.util.spec.js.map |
@@ -116,3 +116,2 @@ import { TextUtil } from './text.util'; | ||
const list = TextUtil.csvToObjects(csv, ';'); | ||
console.log('csv result', list); | ||
expect(list.length).toBe(3); | ||
@@ -119,0 +118,0 @@ expect(list[1].age).toBe(34); |
{ | ||
"name": "@ukon1990/js-utilities", | ||
"version": "1.6.1", | ||
"version": "1.6.2", | ||
"description": "A light weight package for object and array manipulation. As well as some utilities for matching text.", | ||
@@ -33,30 +33,30 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@angular-devkit/build-angular": "~0.801.0", | ||
"@angular/cli": "~8.1.0", | ||
"@angular/compiler": "~8.1.0", | ||
"@angular/compiler-cli": "~8.1.0", | ||
"@angular/core": "~8.1.0", | ||
"@angular/language-service": "~8.1.0", | ||
"@types/jasmine": "~3.3.8", | ||
"@types/jasminewd2": "~2.0.3", | ||
"@types/node": "~8.9.4", | ||
"codelyzer": "^5.0.0", | ||
"@angular-devkit/build-angular": "~0.802.2", | ||
"@angular/cli": "~8.2.2", | ||
"@angular/compiler": "~8.2.2", | ||
"@angular/compiler-cli": "~8.2.2", | ||
"@angular/core": "~8.2.2", | ||
"@angular/language-service": "~8.2.2", | ||
"@types/jasmine": "~3.4.0", | ||
"@types/jasminewd2": "~2.0.6", | ||
"@types/node": "~12.7.2", | ||
"codelyzer": "^5.1.0", | ||
"jasmine-core": "~3.4.0", | ||
"jasmine-spec-reporter": "~4.2.1", | ||
"karma": "^4.1.0", | ||
"karma-chrome-launcher": "~2.2.0", | ||
"karma": "^4.2.0", | ||
"karma-chrome-launcher": "~3.1.0", | ||
"karma-coverage": "^1.1.2", | ||
"karma-coverage-istanbul-reporter": "~2.0.1", | ||
"karma-coverage-istanbul-reporter": "~2.1.0", | ||
"karma-jasmine": "~2.0.1", | ||
"karma-jasmine-html-reporter": "^1.4.0", | ||
"karma-jasmine-html-reporter": "^1.4.2", | ||
"karma-typescript": "^4.1.1", | ||
"protractor": "~5.4.0", | ||
"rxjs": "~6.4.0", | ||
"ts-loader": "^5.3.3", | ||
"ts-node": "~7.0.0", | ||
"tslint": "~5.15.0", | ||
"typescript": "3.1.6", | ||
"webpack": "^4.29.0", | ||
"zone.js": "^0.9.1" | ||
"protractor": "~5.4.2", | ||
"rxjs": "~6.5.2", | ||
"ts-loader": "^6.0.4", | ||
"ts-node": "~8.3.0", | ||
"tslint": "~5.18.0", | ||
"typescript": "3.5.3", | ||
"webpack": "^4.39.2", | ||
"zone.js": "^0.10.2" | ||
} | ||
} |
@@ -167,4 +167,6 @@ import {ArrayUtil} from './array.util'; | ||
it('randomOrder', () => { | ||
const list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; | ||
describe('randomOrder', () => { | ||
it('the list has the same length and unequal', () => { | ||
const list = [...Array(100).keys()]; | ||
const list1 = ArrayUtil.randomOrder(list); | ||
@@ -177,3 +179,17 @@ const list2 = ArrayUtil.randomOrder(list); | ||
ArrayUtil.isEqual(list1, list2)).toBeFalsy(); | ||
}); | ||
it('does not contain undefined values', () => { | ||
const list = [...Array(10000).keys()]; | ||
expect( | ||
ArrayUtil.randomOrder(list) | ||
.filter(n => n === undefined).length) | ||
.toBe(0); | ||
expect( | ||
ArrayUtil.randomOrder(list) | ||
.filter(n => n === undefined).length) | ||
.toBe(0); | ||
}); | ||
}); | ||
}); |
@@ -143,3 +143,8 @@ import {EmptyUtil} from './empty.util'; | ||
for(let i = 0, length = array.length; i < length; i++) { | ||
const index = Math.round(Math.random() * tmp.length); | ||
let index = Math.round(Math.random() * tmp.length - 1); | ||
if (index < 0) { | ||
index = 0; | ||
} | ||
random.push(tmp[index]); | ||
@@ -146,0 +151,0 @@ ArrayUtil.removeIndexes([index], tmp); |
@@ -143,3 +143,2 @@ import {TextUtil} from './text.util'; | ||
const list = TextUtil.csvToObjects<any>(csv, ';'); | ||
console.log('csv result', list); | ||
@@ -146,0 +145,0 @@ expect(list.length).toBe(3); |
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
209120
3137