2018-11-30

2018-11-30  本文已影响0人  Donley828

Work

1.Submit saas4.1 tests
1.Add crm-privilege script

TC39

Standard Library Proposal
Status: Stage 1
1.Protected namespace

2.Import Semantics
Using a features from the standard library can be done through a regular import from protected namespace:

import { Date } from "std:Date";
import { Date } from "std:Date+2.1.6-alpha.1";

const d = new Date(2018, 7, 1);

3.Generic Functions
The advantage of using regular imports is that it allows the development of more generic functions in the standard library. Examples that could be thought of (and exist in other languages like Python) could be:

import { len, map } from "std:builtins";

const ar = [1, 2, 3];
const st = new Set([4, 5, 6, 7]);
const mp = new Map([["e", 8], ["n", 9], ["z", 0], ["o", 1], ["t", 2]);

len(ar); // => 3
len(st); // => 4
len(mp); // => 4

map(ar, (val, idx) => val * 2); // => Array {2, 4, 6}
map(st, (val, idx) => val * 2); // => Set {8, 10, 12, 14}
map(mp, (val, key) => val * 2); // => Map { e: 16, n: 18, z: 0, o: 2 }
上一篇下一篇

猜你喜欢

热点阅读