Skip to content
This repository was archived by the owner on Jan 19, 2022. It is now read-only.

Commit 68342f8

Browse files
author
Michael Perrotte
committedMar 2, 2020
fix: remove unnecessary promises [PR feedback]
1 parent 25fd13f commit 68342f8

File tree

1 file changed

+28
-40
lines changed

1 file changed

+28
-40
lines changed
 

‎index.js

+28-40
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const eu = encodeURIComponent
44
const npmFetch = require('npm-registry-fetch')
55
const validate = require('aproba')
66

7-
const cmd = module.exports = {}
7+
const cmd = module.exports
88

99
cmd.create = (entity, opts = {}) => {
1010
return Promise.resolve().then(() => {
@@ -21,51 +21,42 @@ cmd.create = (entity, opts = {}) => {
2121
}
2222

2323
cmd.destroy = (entity, opts = {}) => {
24-
return Promise.resolve().then(() => {
25-
const { scope, team } = splitEntity(entity)
26-
validate('SSO', [scope, team, opts])
27-
const uri = `/-/team/${eu(scope)}/${eu(team)}`
28-
return npmFetch.json(uri, {
29-
...opts,
30-
method: 'DELETE',
31-
scope
32-
})
24+
const { scope, team } = splitEntity(entity)
25+
validate('SSO', [scope, team, opts])
26+
const uri = `/-/team/${eu(scope)}/${eu(team)}`
27+
return npmFetch.json(uri, {
28+
...opts,
29+
method: 'DELETE',
30+
scope
3331
})
3432
}
3533

3634
cmd.add = (user, entity, opts = {}) => {
37-
return Promise.resolve().then(() => {
38-
const { scope, team } = splitEntity(entity)
39-
validate('SSO', [scope, team, opts])
40-
const uri = `/-/team/${eu(scope)}/${eu(team)}/user`
41-
return npmFetch.json(uri, {
42-
...opts,
43-
method: 'PUT',
44-
scope,
45-
body: { user }
46-
})
35+
const { scope, team } = splitEntity(entity)
36+
validate('SSO', [scope, team, opts])
37+
const uri = `/-/team/${eu(scope)}/${eu(team)}/user`
38+
return npmFetch.json(uri, {
39+
...opts,
40+
method: 'PUT',
41+
scope,
42+
body: { user }
4743
})
4844
}
4945

5046
cmd.rm = (user, entity, opts = {}) => {
51-
return Promise.resolve().then(() => {
52-
const { scope, team } = splitEntity(entity)
53-
validate('SSO', [scope, team, opts])
54-
const uri = `/-/team/${eu(scope)}/${eu(team)}/user`
55-
return npmFetch.json(uri, {
56-
...opts,
57-
method: 'DELETE',
58-
scope,
59-
body: { user }
60-
})
47+
const { scope, team } = splitEntity(entity)
48+
validate('SSO', [scope, team, opts])
49+
const uri = `/-/team/${eu(scope)}/${eu(team)}/user`
50+
return npmFetch.json(uri, {
51+
...opts,
52+
method: 'DELETE',
53+
scope,
54+
body: { user }
6155
})
6256
}
6357

64-
cmd.lsTeams = (scope, opts = {}) => {
65-
return Promise.resolve().then(() => {
66-
return cmd.lsTeams.stream(scope, { ...opts }).collect()
67-
})
68-
}
58+
cmd.lsTeams = (...args) => cmd.lsTeams.stream(...args).collect()
59+
6960
cmd.lsTeams.stream = (scope, opts = {}) => {
7061
validate('SO', [scope, opts])
7162
const uri = `/-/org/${eu(scope)}/team`
@@ -75,11 +66,8 @@ cmd.lsTeams.stream = (scope, opts = {}) => {
7566
})
7667
}
7768

78-
cmd.lsUsers = (entity, opts = {}) => {
79-
return Promise.resolve().then(() => {
80-
return cmd.lsUsers.stream(entity, { ...opts }).collect()
81-
})
82-
}
69+
cmd.lsUsers = (...args) => cmd.lsUsers.stream(...args).collect()
70+
8371
cmd.lsUsers.stream = (entity, opts = {}) => {
8472
const { scope, team } = splitEntity(entity)
8573
validate('SSO', [scope, team, opts])

0 commit comments

Comments
 (0)
This repository has been archived.