Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
deno
提交
ffb41e61
D
deno
项目概览
张重言
/
deno
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
deno
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ffb41e61
编写于
10月 08, 2018
作者:
K
Kitson Kelly
提交者:
Ryan Dahl
10月 07, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updates to js to clean up default library
上级
1aa7e18b
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
39 addition
and
37 deletion
+39
-37
js/blob.ts
js/blob.ts
+9
-6
js/console.ts
js/console.ts
+2
-0
js/errors.ts
js/errors.ts
+9
-9
js/fetch.ts
js/fetch.ts
+14
-22
js/file_info.ts
js/file_info.ts
+1
-0
js/os.ts
js/os.ts
+2
-0
js/trace.ts
js/trace.ts
+1
-0
js/types.ts
js/types.ts
+1
-0
未找到文件。
js/blob.ts
浏览文件 @
ffb41e61
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
import
{
Blob
,
BlobPart
,
BlobPropertyBag
}
from
"
./dom_types
"
;
import
*
as
domTypes
from
"
./dom_types
"
;
import
{
containsOnlyASCII
}
from
"
./util
"
;
const
bytesSymbol
=
Symbol
(
"
bytes
"
);
export
class
DenoBlob
implements
Blob
{
export
class
DenoBlob
implements
domTypes
.
Blob
{
private
readonly
[
bytesSymbol
]:
Uint8Array
;
readonly
size
:
number
=
0
;
readonly
type
:
string
=
""
;
constructor
(
blobParts
?:
BlobPart
[],
options
?:
BlobPropertyBag
)
{
constructor
(
blobParts
?:
domTypes
.
BlobPart
[],
options
?:
domTypes
.
BlobPropertyBag
)
{
if
(
arguments
.
length
===
0
)
{
this
[
bytesSymbol
]
=
new
Uint8Array
();
return
;
...
...
@@ -53,8 +56,8 @@ export class DenoBlob implements Blob {
}
function
processBlobParts
(
blobParts
:
BlobPart
[],
options
:
BlobPropertyBag
blobParts
:
domTypes
.
BlobPart
[],
options
:
domTypes
.
BlobPropertyBag
):
Uint8Array
{
const
normalizeLineEndingsToNative
=
options
.
ending
===
"
native
"
;
// ArrayBuffer.transfer is not yet implemented in V8, so we just have to
...
...
@@ -77,7 +80,7 @@ function processBlobParts(
}
function
toUint8Arrays
(
blobParts
:
BlobPart
[],
blobParts
:
domTypes
.
BlobPart
[],
doNormalizeLineEndingsToNative
:
boolean
):
Uint8Array
[]
{
const
ret
:
Uint8Array
[]
=
[];
...
...
js/console.ts
浏览文件 @
ffb41e61
...
...
@@ -149,6 +149,7 @@ function stringifyWithQuotes(
}
}
// @internal
export
function
stringifyArgs
(
// tslint:disable-next-line:no-any
args
:
any
[],
...
...
@@ -178,6 +179,7 @@ export function stringifyArgs(
type
PrintFunc
=
(
x
:
string
,
isErr
?:
boolean
)
=>
void
;
export
class
Console
{
// @internal
constructor
(
private
printFunc
:
PrintFunc
)
{}
// tslint:disable-next-line:no-any
...
...
js/errors.ts
浏览文件 @
ffb41e61
import
*
as
msg
from
"
gen/msg_generated
"
;
import
{
Base
,
ErrorKind
}
from
"
gen/msg_generated
"
;
export
{
ErrorKind
}
from
"
gen/msg_generated
"
;
// @internal
export
class
DenoError
<
T
extends
msg
.
ErrorKind
>
extends
Error
{
constructor
(
readonly
kind
:
T
,
errStr
:
string
)
{
super
(
errStr
);
this
.
name
=
msg
.
ErrorKind
[
kind
];
export
class
DenoError
<
T
extends
ErrorKind
>
extends
Error
{
constructor
(
readonly
kind
:
T
,
msg
:
string
)
{
super
(
msg
);
this
.
name
=
ErrorKind
[
kind
];
}
}
// @internal
export
function
maybeThrowError
(
base
:
msg
.
Base
):
void
{
export
function
maybeThrowError
(
base
:
Base
):
void
{
const
err
=
maybeError
(
base
);
if
(
err
!=
null
)
{
throw
err
;
}
}
export
function
maybeError
(
base
:
msg
.
Base
):
null
|
DenoError
<
msg
.
ErrorKind
>
{
// @internal
export
function
maybeError
(
base
:
Base
):
null
|
DenoError
<
ErrorKind
>
{
const
kind
=
base
.
errorKind
();
if
(
kind
===
msg
.
ErrorKind
.
NoError
)
{
if
(
kind
===
ErrorKind
.
NoError
)
{
return
null
;
}
else
{
return
new
DenoError
(
kind
,
base
.
error
()
!
);
...
...
js/fetch.ts
浏览文件 @
ffb41e61
...
...
@@ -10,23 +10,15 @@ import {
import
{
flatbuffers
}
from
"
flatbuffers
"
;
import
{
sendAsync
}
from
"
./dispatch
"
;
import
*
as
msg
from
"
gen/msg_generated
"
;
import
{
Headers
,
Request
,
Response
,
Blob
,
RequestInit
,
HeadersInit
,
FormData
}
from
"
./dom_types
"
;
import
*
as
domTypes
from
"
./dom_types
"
;
import
{
TextDecoder
}
from
"
./text_encoding
"
;
import
{
DenoBlob
}
from
"
./blob
"
;
// ref: https://fetch.spec.whatwg.org/#dom-headers
export
class
DenoHeaders
implements
Headers
{
export
class
DenoHeaders
implements
domTypes
.
Headers
{
private
headerMap
:
Map
<
string
,
string
>
=
new
Map
();
constructor
(
init
?:
HeadersInit
)
{
constructor
(
init
?:
domTypes
.
HeadersInit
)
{
if
(
arguments
.
length
===
0
||
init
===
undefined
)
{
return
;
}
...
...
@@ -95,7 +87,7 @@ export class DenoHeaders implements Headers {
}
forEach
(
callbackfn
:
(
value
:
string
,
key
:
string
,
parent
:
Headers
)
=>
void
,
callbackfn
:
(
value
:
string
,
key
:
string
,
parent
:
domTypes
.
Headers
)
=>
void
,
// tslint:disable-next-line:no-any
thisArg
?:
any
):
void
{
...
...
@@ -105,7 +97,7 @@ export class DenoHeaders implements Headers {
}
}
class
FetchResponse
implements
Response
{
class
FetchResponse
implements
domTypes
.
Response
{
readonly
url
:
string
=
""
;
body
:
null
;
bodyUsed
=
false
;
// TODO
...
...
@@ -113,7 +105,7 @@ class FetchResponse implements Response {
readonly
type
=
"
basic
"
;
// TODO
redirected
=
false
;
// TODO
headers
:
DenoHeaders
;
readonly
trailer
:
Promise
<
Headers
>
;
readonly
trailer
:
Promise
<
domTypes
.
Headers
>
;
//private bodyChunks: Uint8Array[] = [];
private
first
=
true
;
private
bodyWaiter
:
Resolvable
<
ArrayBuffer
>
;
...
...
@@ -135,16 +127,16 @@ class FetchResponse implements Response {
return
this
.
bodyWaiter
;
}
async
blob
():
Promise
<
Blob
>
{
async
blob
():
Promise
<
domTypes
.
Blob
>
{
const
arrayBuffer
=
await
this
.
arrayBuffer
();
return
new
DenoBlob
([
arrayBuffer
],
{
type
:
this
.
headers
.
get
(
"
content-type
"
)
||
""
});
}
async
formData
():
Promise
<
FormData
>
{
async
formData
():
Promise
<
domTypes
.
FormData
>
{
notImplemented
();
return
{}
as
FormData
;
return
{}
as
domTypes
.
FormData
;
}
async
json
():
Promise
<
object
>
{
...
...
@@ -162,9 +154,9 @@ class FetchResponse implements Response {
return
200
<=
this
.
status
&&
this
.
status
<
300
;
}
clone
():
Response
{
clone
():
domTypes
.
Response
{
notImplemented
();
return
{}
as
Response
;
return
{}
as
domTypes
.
Response
;
}
onHeader
?:
(
res
:
FetchResponse
)
=>
void
;
...
...
@@ -187,9 +179,9 @@ class FetchResponse implements Response {
}
export
async
function
fetch
(
input
?:
Request
|
string
,
init
?:
RequestInit
):
Promise
<
Response
>
{
input
?:
domTypes
.
Request
|
string
,
init
?:
domTypes
.
RequestInit
):
Promise
<
domTypes
.
Response
>
{
const
url
=
input
as
string
;
log
(
"
dispatch FETCH_REQ
"
,
url
);
...
...
js/file_info.ts
浏览文件 @
ffb41e61
...
...
@@ -61,6 +61,7 @@ export interface FileInfo {
isSymlink
():
boolean
;
}
// @internal
export
class
FileInfoImpl
implements
FileInfo
{
readonly
_isFile
:
boolean
;
readonly
_isSymlink
:
boolean
;
...
...
js/os.ts
浏览文件 @
ffb41e61
...
...
@@ -15,6 +15,7 @@ export function exit(exitCode = 0): never {
return
util
.
unreachable
();
}
// @internal
export
function
codeFetch
(
moduleSpecifier
:
string
,
containingFile
:
string
...
...
@@ -44,6 +45,7 @@ export function codeFetch(
};
}
// @internal
export
function
codeCache
(
filename
:
string
,
sourceCode
:
string
,
...
...
js/trace.ts
浏览文件 @
ffb41e61
...
...
@@ -41,6 +41,7 @@ function popStack(): TraceInfo[] {
}
// Push to trace stack if we are tracing
// @internal
export
function
maybePushTrace
(
op
:
msg
.
Any
,
sync
:
boolean
):
void
{
if
(
current
===
null
)
{
return
;
// no trace requested
...
...
js/types.ts
浏览文件 @
ffb41e61
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
export
type
TypedArray
=
Uint8Array
|
Float32Array
|
Int32Array
;
// @internal
export
interface
ModuleInfo
{
moduleName
:
string
|
null
;
filename
:
string
|
null
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录