FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
optimized/optimized.js at master · node-modules/optimized · GitHub
node-modules
optimized
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
optimized
/
optimized.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
93 lines (83 loc) · 1.68 KB
Breadcrumbs
optimized
/
optimized.js
Copy path
File metadata and controls
93 lines (83 loc) · 1.68 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**!
* optimized - index.js
*
* Copyright(c) fengmk2 and other contributors.
* MIT Licensed
*
* Authors:
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.github.com)
*/
'use strict'
;
/**
* Module dependencies.
*/
var
fmt
=
require
(
'util'
)
.
format
;
require
(
'colors'
)
;
function
printStatus
(
fn
,
args
,
data
)
{
var
argsString
=
''
;
if
(
args
)
{
argsString
=
args
.
map
(
function
(
a
)
{
return
JSON
.
stringify
(
a
)
;
}
)
.
join
(
', '
)
;
}
console
.
log
(
fmt
(
'Function %s(%s) is %s'
,
fn
.
_name
||
fn
.
name
||
'anonymous'
,
argsString
,
data
.
result
)
[
data
.
color
]
)
;
}
function
detect
(
fn
)
{
var
result
=
'unknow'
;
var
optimized
=
false
;
var
color
=
'grey'
;
switch
(
%
GetOptimizationStatus
(
fn
)
)
{
case
1
:
result
=
'optimized'
;
optimized
=
true
;
color
=
'green'
;
break
;
case
2
:
result
=
'not optimized'
;
optimized
=
false
;
color
=
'red'
;
break
;
case
3
:
result
=
'always optimized'
;
optimized
=
true
;
color
=
'green'
;
break
;
case
4
:
result
=
'never optimized'
;
optimized
=
false
;
color
=
'red'
;
break
;
case
6
:
result
=
'maybe deoptimized'
;
optimized
=
false
;
color
=
'yellow'
;
break
;
}
return
{
optimized
:
optimized
,
result
:
result
,
color
:
color
}
;
}
function
optimized
(
fn
,
args
,
ctx
)
{
// Fill type-info
if
(
args
)
{
fn
.
apply
(
ctx
,
args
)
;
}
else
{
fn
(
)
;
}
%
OptimizeFunctionOnNextCall
(
fn
)
;
// The next call
if
(
args
)
{
fn
.
apply
(
ctx
,
args
)
;
}
else
{
fn
(
)
;
}
// Check
var
data
=
detect
(
fn
)
;
printStatus
(
fn
,
args
,
data
)
;
return
data
.
optimized
;
}
module
.
exports
=
optimized
;
module
.
exports
.
detect
=
detect
;
Back
|
FazBrowse Home
|
New Git URL