Skip to content

Commit 992087b

Browse files
Setting up the script.
1 parent 66fc21d commit 992087b

File tree

4 files changed

+35
-8
lines changed

4 files changed

+35
-8
lines changed

.babelrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"presets": ["@babel/preset-typescript"],
3+
"plugins": ["@babel/plugin-transform-modules-umd"],
4+
"filename": "array-of-objects.js",
5+
"sourceFileName": "array-of-objects.ts",
6+
"filenameRelative": "array-of-objects.ts",
7+
"moduleRoot": "src"
8+
}

.browserslistrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
last 10 version
2+
not dead
3+
IE 10
4+
IE 9
5+
IE 8
6+
IE 7

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22
"name": "array-of-objects",
33
"version": "0.1.0",
44
"description": "Useful functions to use with array of objects.",
5-
"main": "index.js",
5+
"main": "lib/array-of-objects.ts",
6+
"repository": "git@github.com:viktor-maksimov/array-of-objects.git",
67
"author": "viktor-maksimov <viktor.slavov.maksimov@gmail.com>",
78
"license": "MIT",
89
"private": false,
910
"keywords": ["array", "object", "unique"],
1011
"homepage": "https://github.com/viktor-maksimov/array-of-objects",
1112
"bugs": "https://github.com/viktor-maksimov/array-of-objects/issues",
12-
"repository": {
13-
"url": "https://github.com/viktor-maksimov/array-of-objects",
14-
"type": "git"
15-
},
16-
"dependencies": {
17-
13+
"scripts": {
14+
"build": "babel --presets @babel/preset-typescript src/array-of-objects.ts -d lib"
1815
},
16+
"dependencies": {},
1917
"devDependencies": {
2018
"@babel/cli": "^7.0.0",
21-
"@babel/core": "^7.0.0"
19+
"@babel/core": "^7.0.0",
20+
"@babel/plugin-transform-modules-umd": "^7.2.0",
21+
"@babel/preset-typescript": "^7.3.3"
2222
}
2323
}

src/array-of-objects.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export function getUniqueValues(arrayOfObjects: Object[], propertyName): Array<any> {
2+
const output: Array<any> = []
3+
4+
arrayOfObjects.map(obj => {
5+
if (obj[propertyName] !== undefined) {
6+
if (output.find(val => obj[propertyName] === val) === undefined) {
7+
output.push(obj[propertyName])
8+
}
9+
}
10+
})
11+
12+
return output
13+
}

0 commit comments

Comments
 (0)