Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
deno
提交
3de9540a
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,发现更多精彩内容 >>
未验证
提交
3de9540a
编写于
1月 30, 2020
作者:
C
Chris Knight
提交者:
GitHub
1月 30, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(std/node) Endianness (#3833)
上级
de5c099b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
19 addition
and
10 deletion
+19
-10
std/node/os.ts
std/node/os.ts
+12
-3
std/node/os_test.ts
std/node/os_test.ts
+7
-7
未找到文件。
std/node/os.ts
浏览文件 @
3de9540a
...
...
@@ -19,6 +19,7 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
import
{
notImplemented
}
from
"
./_utils.ts
"
;
import
{
EOL
as
fsEOL
}
from
"
../fs/eol.ts
"
;
const
SEE_GITHUB_ISSUE
=
"
See https://github.com/denoland/deno/issues/3802
"
;
...
...
@@ -96,9 +97,17 @@ export function cpus(): CPUCoreInfo[] {
notImplemented
(
SEE_GITHUB_ISSUE
);
}
/** Not yet implemented */
/**
* Returns a string identifying the endianness of the CPU for which the Deno
* binary was compiled. Possible values are 'BE' for big endian and 'LE' for
* little endian.
**/
export
function
endianness
():
"
BE
"
|
"
LE
"
{
notImplemented
(
SEE_GITHUB_ISSUE
);
// Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView#Endianness
const
buffer
=
new
ArrayBuffer
(
2
);
new
DataView
(
buffer
).
setInt16
(
0
,
256
,
true
/* littleEndian */
);
// Int16Array uses the platform's endianness.
return
new
Int16Array
(
buffer
)[
0
]
===
256
?
"
LE
"
:
"
BE
"
;
}
/** Not yet implemented */
...
...
@@ -201,7 +210,7 @@ export const constants = {
}
};
export
const
EOL
=
Deno
.
build
.
os
==
"
win
"
?
"
\r\n
"
:
"
\n
"
;
export
const
EOL
=
Deno
.
build
.
os
==
"
win
"
?
fsEOL
.
CRLF
:
fsEOL
.
LF
;
const
validateInt32
=
(
value
:
number
,
...
...
std/node/os_test.ts
浏览文件 @
3de9540a
...
...
@@ -154,6 +154,13 @@ test({
}
});
test
({
name
:
"
Endianness is determined
"
,
fn
()
{
assert
([
"
LE
"
,
"
BE
"
].
includes
(
os
.
endianness
()));
}
});
// Method is currently implemented correctly for windows but not for any other os
test
({
name
:
"
Load average is an array of 3 numbers
"
,
...
...
@@ -187,13 +194,6 @@ test({
Error
,
"
Not implemented
"
);
assertThrows
(
()
=>
{
os
.
endianness
();
},
Error
,
"
Not implemented
"
);
assertThrows
(
()
=>
{
os
.
freemem
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录