- module es7.string.at js String #at(index) -> string CommonJS entry points: js core-js(/library)/fn/string/at core-js(/library)/fn/string/virtual/at Examples: js 'a𠮷b'.at(1); // => '𠮷' 'a𠮷b'.at(1).length; // => 2
  • Map#toJSON, Set#toJSON proposal - modules es7.map.to-json, es7.set.to-json (rejected and will be removed from core-js@3) js Map #toJSON() -> array (rejected and will be removed from core-js@3) Set #toJSON() -> array (rejected and will be removed from core-js@3) CommonJS entry points: js core-js(/library)/fn/map core-js(/library)/fn/set
  • Error.isError proposal - module es7.error.is-error (withdrawn and will be removed from core-js@3) js Error .isError(it) -> bool (withdrawn and will be removed from core-js@3) CommonJS entry points: js core-js(/library)/fn/error/is-error
  • Math.{iaddh, isubh, imulh, umulh} proposal - modules es7.math.iaddh, es7.math.isubh, es7.math.imulh and es7.math.umulh js Math .iaddh(lo0, hi0, lo1, hi1) -> int32 .isubh(lo0, hi0, lo1, hi1) -> int32 .imulh(a, b) -> int32 .umulh(a, b) -> uint32 CommonJS entry points: js core-js(/library)/fn/math/iaddh core-js(/library)/fn/math/isubh core-js(/library)/fn/math/imulh core-js(/library)/fn/math/umulh
  • global.asap, TC39 discussion, module es7.asap js asap(fn) -> void CommonJS entry points: js core-js(/library)/fn/asap Examples: js asap(() => console.log('called as microtask'));
  • Pre-stage 0 proposals

    CommonJS entry points:

    core-js(/library)/stage/pre
    

    Web standards

    CommonJS entry points:

    core-js(/library)/web
    

    setTimeout / setInterval

    Module web.timers. Additional arguments fix for IE9-.

    setTimeout(fn(...args), time, ...args) -> id
    setInterval(fn(...args), time, ...args) -> id
    

    CommonJS entry points:

    core-js(/library)/web/timers
    core-js(/library)/fn/set-timeout
    core-js(/library)/fn/set-interval
    
    // Before:
    setTimeout(log.bind(null, 42), 1000);
    // After:
    setTimeout(log, 1000, 42);
    

    setImmediate

    Module web.immediate. setImmediate proposal polyfill.

    setImmediate(fn(...args), ...args) -> id
    clearImmediate(id) -> void
    

    CommonJS entry points:

    core-js(/library)/web/immediate
    core-js(/library)/fn/set-immediate
    core-js(/library)/fn/clear-immediate
    

    Examples:

    setImmediate(function(arg1, arg2){
      console.log(arg1, arg2); // => Message will be displayed with minimum delay
    }, 'Message will be displayed', 'with minimum delay');
    
    clearImmediate(setImmediate(function(){
      console.log('Message will not be displayed');
    }));
    

    Iterable DOM collections

    Some DOM collections should have iterable interface or should be inherited from Array. That mean they should have keys, values, entries and @@iterator methods for iteration. So add them. Module web.dom.iterable:

    {
      CSSRuleList,
      CSSStyleDeclaration,
      CSSValueList,
      ClientRectList,
      DOMRectList,
      DOMStringList,
      DOMTokenList,
      DataTransferItemList,
      FileList,
      HTMLAllCollection,
      HTMLCollection,
      HTMLFormElement,
      HTMLSelectElement,
      MediaList,
      MimeTypeArray,
      NamedNodeMap,
      NodeList,
      PaintRequestList,
      Plugin,
      PluginArray,
      SVGLengthList,
      SVGNumberList,
      SVGPathSegList,
      SVGPointList,
      SVGStringList,
      SVGTransformList,
      SourceBufferList,
      StyleSheetList,
      TextTrackCueList,
      TextTrackList,
      TouchList
    }
      #@@iterator() -> iterator (values)
    
    {
      DOMTokenList,
      NodeList
    }
      #values()  -> iterator
      #keys()    -> iterator
      #entries() -> iterator
    

    CommonJS entry points:

    core-js(/library)/web/dom-collections
    core-js(/library)/fn/dom-collections/iterator
    

    Examples:

    for(var {id} of document.querySelectorAll('*')){
      if(id)console.log(id);
    }
    
    for(var [index, {id}] of document.querySelectorAll('*').entries()){
      if(id)console.log(index, id);
    }
    

    Non-standard

    CommonJS entry points:

    core-js(/library)/core
    

    Object

    Modules core.object.is-object, core.object.classof, core.object.define, core.object.make.

    Object
      .isObject(var) -> bool
      .classof(var) -> string
      .define(target, mixin) -> target
      .make(proto | null, mixin?) -> object
    

    CommonJS entry points:

    core-js(/library)/core/object
    core-js(/library)/fn/object/is-object
    core-js(/library)/fn/object/define
    core-js(/library)/fn/object/make
    

    Object classify examples:

    Object.isObject({});    // => true
    Object.isObject(isNaN); // => true
    Object.isObject(null);  // => false
    
    var classof = Object.classof;
    
    classof(null);                 // => 'Null'
    classof(undefined);            // => 'Undefined'
    classof(1);                    // => 'Number'
    classof(true);                 // => 'Boolean'
    classof('string');             // => 'String'
    classof(Symbol());             // => 'Symbol'
    
    classof(new Number(1));        // => 'Number'
    classof(new Boolean(true));    // => 'Boolean'
    classof(new String('string')); // => 'String'
    
    var fn   = function(){}
      , list = (function(){return arguments})(1, 2, 3);
    
    classof({});                   // => 'Object'
    classof(fn);                   // => 'Function'
    classof([]);                   // => 'Array'
    classof(list);                 // => 'Arguments'
    classof(/./);                  // => 'RegExp'
    classof(new TypeError);        // => 'Error'
    
    classof(new Set);              // => 'Set'
    classof(new Map);              // => 'Map'
    classof(new WeakSet);          // => 'WeakSet'
    classof(new WeakMap);          // => 'WeakMap'
    classof(new Promise(fn));      // => 'Promise'
    
    classof([].values());          // => 'Array Iterator'
    classof(new Set().values());   // => 'Set Iterator'
    classof(new Map().values());   // => 'Map Iterator'
    
    classof(Math);                 // => 'Math'
    classof(JSON);                 // => 'JSON'
    
    function Example(){}
    Example.prototype[Symbol.toStringTag] = 'Example';
    
    classof(new Example);          // => 'Example'
    

    Object.define and Object.make examples:

    // Before:
    Object.defineProperty(target, 'c', {
      enumerable: true,
      configurable: true,
      get: function(){
        return this.a + this.b;
      }
    });
    
    // After:
    Object.define(target, {
      get c(){
        return this.a + this.b;
      }
    });
    
    // Shallow object cloning with prototype and descriptors:
    var copy = Object.make(Object.getPrototypeOf(src), src);
    
    // Simple inheritance:
    function Vector2D(x, y){
      this.x = x;
      this.y = y;
    }
    Object.define(Vector2D.prototype, {
      get xy(){
        return Math.hypot(this.x, this.y);
      }
    });
    function Vector3D(x, y, z){
      Vector2D.apply(this, arguments);
      this.z = z;
    }
    Vector3D.prototype = Object.make(Vector2D.prototype, {
      constructor: Vector3D,
      get xyz(){
        return Math.hypot(this.x, this.y, this.z);
      }
    });
    
    var vector = new Vector3D(9, 12, 20);
    console.log(vector.xy);  // => 15
    console.log(vector.xyz); // => 25
    vector.y++;
    console.log(vector.xy);  // => 15.811388300841896
    console.log(vector.xyz); // => 25.495097567963924
    

    Dict

    Module core.dict. Based on TC39 discuss / strawman.

    [new] Dict(iterable (entries) | object ?) -> dict
      .isDict(var) -> bool
      .values(object) -> iterator
      .keys(object) -> iterator
      .entries(object) -> iterator (entries)
      .has(object, key) -> bool
      .get(object, key) -> val
      .set(object, key, value) -> object
      .forEach(object, fn(val, key, @), that) -> void
      .map(object, fn(val, key, @), that) -> new @
      .mapPairs(object, fn(val, key, @), that) -> new @
      .filter(object, fn(val, key, @), that) -> new @
      .some(object, fn(val, key, @), that) -> bool
      .every(object, fn(val, key, @), that) -> bool
      .find(object, fn(val, key, @), that) -> val
      .findKey(object, fn(val, key, @), that) -> key
      .keyOf(object, var) -> key
      .includes(object, var) -> bool
      .reduce(object, fn(memo, val, key, @), memo?) -> var
    

    CommonJS entry points:

    core-js(/library)/core/dict
    core-js(/library)/fn/dict
    

    Dict create object without prototype from iterable or simple object.

    Examples:

    var map = new Map([['a', 1], ['b', 2], ['c', 3]]);
    
    Dict();                    // => {__proto__: null}
    Dict({a: 1, b: 2, c: 3});  // => {__proto__: null, a: 1, b: 2, c: 3}
    Dict(map);                 // => {__proto__: null, a: 1, b: 2, c: 3}
    Dict([1, 2, 3].entries()); // => {__proto__: null, 0: 1, 1: 2, 2: 3}
    
    var dict = Dict({a: 42});
    dict instanceof Object;   // => false
    dict.a;                   // => 42
    dict.toString;            // => undefined
    'a' in dict;              // => true
    'hasOwnProperty' in dict; // => false
    
    Dict.isDict({});     // => false
    Dict.isDict(Dict()); // => true
    

    Dict.keys, Dict.values and Dict.entries returns iterators for objects.

    Examples:

    var dict = {a: 1, b: 2, c: 3};
    
    for(var key of Dict.keys(dict))console.log(key); // => 'a', 'b', 'c'
    
    for(var val of Dict.values(dict))console.log(val); // => 1, 2, 3
    
    for(var [key, val] of Dict.entries(dict)){
      console.log(key); // => 'a', 'b', 'c'
      console.log(val); // => 1, 2, 3
    }
    
    new Map(Dict.entries(dict)); // => Map {a: 1, b: 2, c: 3}
    

    Basic dict operations for objects with prototype examples:

    'q' in {q: 1};            // => true
    'toString' in {};         // => true
    
    Dict.has({q: 1}, 'q');    // => true
    Dict.has({}, 'toString'); // => false
    
    ({q: 1})['q'];            // => 1
    ({}).toString;            // => function toString(){ [native code] }
    
    Dict.get({q: 1}, 'q');    // => 1
    Dict.get({}, 'toString'); // => undefined
    
    var O = {};
    O['q'] = 1;
    O['q'];         // => 1
    O['__proto__'] = {w: 2};
    O['__proto__']; // => {w: 2}
    O['w'];         // => 2
    
    var O = {};
    Dict.set(O, 'q', 1);
    O['q'];         // => 1
    Dict.set(O, '__proto__', {w: 2});
    O['__proto__']; // => {w: 2}
    O['w'];         // => undefined
    

    Other methods of Dict module are static equivalents of Array.prototype methods for dictionaries.

    Examples:

    var dict = {a: 1, b: 2, c: 3};
    
    Dict.forEach(dict, console.log, console);
    // => 1, 'a', {a: 1, b: 2, c: 3}
    // => 2, 'b', {a: 1, b: 2, c: 3}
    // => 3, 'c', {a: 1, b: 2, c: 3}
    
    Dict.map(dict, function(it){
      return it * it;
    }); // => {a: 1, b: 4, c: 9}
    
    Dict.mapPairs(dict, function(val, key){
      if(key != 'b')return [key + key, val * val];
    }); // => {aa: 1, cc: 9}
    
    Dict.filter(dict, function(it){
      return it % 2;
    }); // => {a: 1, c: 3}
    
    Dict.some(dict, function(it){
      return it === 2;
    }); // => true
    
    Dict.every(dict, function(it){
      return it === 2;
    }); // => false
    
    Dict.find(dict, function(it){
      return it > 2;
    }); // => 3
    Dict.find(dict, function(it){
      return it > 4;
    }); // => undefined
    
    Dict.findKey(dict, function(it){
      return it > 2;
    }); // => 'c'
    Dict.findKey(dict, function(it){
      return it > 4;
    }); // => undefined
    
    Dict.keyOf(dict, 2);    // => 'b'
    Dict.keyOf(dict, 4);    // => undefined
    
    Dict.includes(dict, 2); // => true
    Dict.includes(dict, 4); // => false
    
    Dict.reduce(dict, function(memo, it){
      return memo + it;
    });     // => 6
    Dict.reduce(dict, function(memo, it){
      return memo + it;
    }, ''); // => '123'
    

    Partial application

    Module core.function.part.

    Function
      #part(...args | _) -> fn(...args)
    

    CommonJS entry points:

    core-js/core/function
    core-js(/library)/fn/function/part
    core-js(/library)/fn/function/virtual/part
    core-js(/library)/fn/_
    

    Function#part partial apply function without this binding. Uses global variable _ (core._ for builds without global namespace pollution) as placeholder and not conflict with Underscore / LoDash.

    Examples:

    var fn1 = log.part(1, 2);
    fn1(3, 4);    // => 1, 2, 3, 4
    
    var fn2 = log.part(_, 2, _, 4);
    fn2(1, 3);    // => 1, 2, 3, 4
    
    var fn3 = log.part(1, _, _, 4);
    fn3(2, 3);    // => 1, 2, 3, 4
    
    fn2(1, 3, 5); // => 1, 2, 3, 4, 5
    fn2(1);       // => 1, 2, undefined, 4
    

    Number Iterator

    Module core.number.iterator.

    Number
      #@@iterator() -> iterator
    

    CommonJS entry points:

    core-js(/library)/core/number
    core-js(/library)/fn/number/iterator
    core-js(/library)/fn/number/virtual/iterator
    

    Examples:

    for(var i of 3)console.log(i); // => 0, 1, 2
    
    [...10]; // => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    
    Array.from(10, Math.random); // => [0.9817775336559862, 0.02720663254149258, ...]
    
    Array.from(10, function(it){
      return this + it * it;
    }, .42); // => [0.42, 1.42, 4.42, 9.42, 16.42, 25.42, 36.42, 49.42, 64.42, 81.42]
    

    Escaping strings

    Modules core.regexp.escape, core.string.escape-html and core.string.unescape-html.

    RegExp
      .escape(str) -> str
    String
      #escapeHTML() -> str
      #unescapeHTML() -> str
    

    CommonJS entry points:

    core-js(/library)/core/regexp
    core-js(/library)/core/string
    core-js(/library)/fn/regexp/escape
    core-js(/library)/fn/string/escape-html
    core-js(/library)/fn/string/unescape-html
    core-js(/library)/fn/string/virtual/escape-html
    core-js(/library)/fn/string/virtual/unescape-html
    

    Examples:

    RegExp.escape('Hello, []{}()*+?.\\^$|!'); // => 'Hello, \[\]\{\}\(\)\*\+\?\.\\\^\$\|!'
    
    '<script>doSomething();</script>'.escapeHTML(); // => '&lt;script&gt;doSomething();&lt;/script&gt;'
    '&lt;script&gt;doSomething();&lt;/script&gt;'.unescapeHTML(); // => '<script>doSomething();</script>'
    

    delay

    Module core.delay. Promise-returning delay function, esdiscuss.

    delay(ms) -> promise
    

    CommonJS entry points:

    core-js(/library)/core/delay
    core-js(/library)/fn/delay
    

    Examples:

    delay(1e3).then(() => console.log('after 1 sec'));
    
    (async () => {
      await delay(3e3);
      console.log('after 3 sec');
    
      while(await delay(3e3))console.log('each 3 sec');
    })();
    

    Helpers for iterators

    Modules core.is-iterable, core.get-iterator, core.get-iterator-method - helpers for check iterability / get iterator in the library version or, for example, for arguments object:

    core
      .isIterable(var) -> bool
      .getIterator(iterable) -> iterator
      .getIteratorMethod(var) -> function | undefined
    

    CommonJS entry points:

    core-js(/library)/fn/is-iterable
    core-js(/library)/fn/get-iterator
    core-js(/library)/fn/get-iterator-method
    

    Examples:

    var list = (function(){
      return arguments;
    })(1, 2, 3);
    
    console.log(core.isIterable(list)); // true;
    
    var iter = core.getIterator(list);
    console.log(iter.next().value); // 1
    console.log(iter.next().value); // 2
    console.log(iter.next().value); // 3
    console.log(iter.next().value); // undefined
    
    core.getIterator({});   // TypeError: [object Object] is not iterable!
    
    var iterFn = core.getIteratorMethod(list);
    console.log(typeof iterFn);     // 'function'
    var iter = iterFn.call(list);
    console.log(iter.next().value); // 1
    console.log(iter.next().value); // 2
    console.log(iter.next().value); // 3
    console.log(iter.next().value); // undefined
    
    console.log(core.getIteratorMethod({})); // undefined
    

    Missing polyfills

    Kodo/kodo - Gogs: Go Git Service

    2 Commits (61d8e8ed4d150e2f51dbe6655882c0007abf3ba4)

    Autore SHA1 Messaggio Data
      Brightcells 7e9b7eb161 Opt 6 anni fa
      Brightcells 88c914df41 Guideline Login Error 6 anni fa