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

Commit 603fc62

Browse files
author
Michael Perrotte
committedFeb 27, 2020
fix: refactored out 'pwrap' function
1 parent 5e6b41e commit 603fc62

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed
 

‎index.js

+6-12
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const validate = require('aproba')
77
const cmd = module.exports = {}
88

99
cmd.create = (entity, opts = { description: undefined }) => {
10-
return pwrap(opts, () => {
10+
return Promise.resolve().then(() => {
1111
const { scope, team } = splitEntity(entity)
1212
validate('SSO', [scope, team, opts])
1313
const uri = `/-/org/${eu(scope)}/team`
@@ -21,7 +21,7 @@ cmd.create = (entity, opts = { description: undefined }) => {
2121
}
2222

2323
cmd.destroy = (entity, opts = {}) => {
24-
return pwrap(opts, () => {
24+
return Promise.resolve().then(() => {
2525
const { scope, team } = splitEntity(entity)
2626
validate('SSO', [scope, team, opts])
2727
const uri = `/-/team/${eu(scope)}/${eu(team)}`
@@ -34,7 +34,7 @@ cmd.destroy = (entity, opts = {}) => {
3434
}
3535

3636
cmd.add = (user, entity, opts = {}) => {
37-
return pwrap(opts, () => {
37+
return Promise.resolve().then(() => {
3838
const { scope, team } = splitEntity(entity)
3939
validate('SSO', [scope, team, opts])
4040
const uri = `/-/team/${eu(scope)}/${eu(team)}/user`
@@ -48,7 +48,7 @@ cmd.add = (user, entity, opts = {}) => {
4848
}
4949

5050
cmd.rm = (user, entity, opts = {}) => {
51-
return pwrap(opts, () => {
51+
return Promise.resolve().then(() => {
5252
const { scope, team } = splitEntity(entity)
5353
validate('SSO', [scope, team, opts])
5454
const uri = `/-/team/${eu(scope)}/${eu(team)}/user`
@@ -62,7 +62,7 @@ cmd.rm = (user, entity, opts = {}) => {
6262
}
6363

6464
cmd.lsTeams = (scope, opts = {}) => {
65-
return pwrap(opts, () => {
65+
return Promise.resolve().then(() => {
6666
return cmd.lsTeams.stream(scope, { ...opts }).collect()
6767
})
6868
}
@@ -76,7 +76,7 @@ cmd.lsTeams.stream = (scope, opts = {}) => {
7676
}
7777

7878
cmd.lsUsers = (entity, opts = {}) => {
79-
return pwrap(opts, () => {
79+
return Promise.resolve().then(() => {
8080
return cmd.lsUsers.stream(entity, { ...opts }).collect()
8181
})
8282
}
@@ -98,9 +98,3 @@ function splitEntity (entity = '') {
9898
const [, scope, team] = entity.match(/^@?([^:]+):(.*)$/) || []
9999
return { scope, team }
100100
}
101-
102-
function pwrap (opts, fn) {
103-
return new Promise((resolve, reject) => {
104-
fn().then(resolve, reject)
105-
})
106-
}

0 commit comments

Comments
 (0)
This repository has been archived.