Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit 37c176a3
authored
Jun 12, 2016
by
Felix Becker
Committed by
Mick Hansen
Jun 12, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ES6 refactor of promise.js (#6081)
let, const, arrow functions, export default
1 parent
93146f73
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
lib/promise.js
lib/promise.js
View file @
37c176a
'use strict'
;
var
Promise
=
require
(
'bluebird'
)
,
shimmer
=
require
(
'shimmer'
);
const
Promise
=
require
(
'bluebird'
);
const
shimmer
=
require
(
'shimmer'
);
// functionName: The Promise function that should be shimmed
// fnArgs: The arguments index that should be CLS enabled (typically all callbacks). Offset from last if negative
function
shimCLS
(
object
,
functionName
,
fnArgs
){
shimmer
.
wrap
(
object
,
functionName
,
f
unction
(
fn
)
{
shimmer
.
wrap
(
object
,
functionName
,
f
n
=>
{
return
function
()
{
if
(
Promise
.
Sequelize
&&
Promise
.
Sequelize
.
cls
)
{
var
ns
=
Promise
.
Sequelize
.
cls
;
for
(
var
x
=
0
;
x
<
fnArgs
.
length
;
x
++
)
{
var
argIndex
=
fnArgs
[
x
]
<
0
?
arguments
.
length
+
fnArgs
[
x
]
:
fnArgs
[
x
];
const
ns
=
Promise
.
Sequelize
.
cls
;
for
(
let
x
=
0
;
x
<
fnArgs
.
length
;
x
++
)
{
const
argIndex
=
fnArgs
[
x
]
<
0
?
arguments
.
length
+
fnArgs
[
x
]
:
fnArgs
[
x
];
if
(
argIndex
<
arguments
.
length
&&
typeof
arguments
[
argIndex
]
===
'function'
)
{
arguments
[
argIndex
]
=
ns
.
bind
(
arguments
[
argIndex
]
);
}
...
...
@@ -51,3 +51,5 @@ shimCLS(Promise.prototype, 'tap', [0]);
shimCLS
(
Promise
.
prototype
,
'done'
,
[
0
,
1
]);
module
.
exports
=
Promise
;
module
.
exports
.
Promise
=
Promise
;
module
.
exports
.
default
=
Promise
;
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment