ES6 module syntax: is it possible to `export * as Name from …`?

No, it’s not allowed in JS either, however there is a proposal to add it. For now, just use the two-step process with importing into a local variable and exporting that: // file: constants.js export const SomeConstant1 = ‘yay’; export const SomeConstant2 = ‘yayayaya’; // file: index.js import * as Constants from ‘./constants.js’; export {Constants};

Is it possible to reset an ECMAScript 6 generator to its initial state?

If your intention is to some other scope, iterate over it, do some other stuff, then be able to iterate over it again later on in that same scope. Then the only thing you shouldn’t try doing is passing the iterator, instead pass the generator: var generator = function*() { yield 1; yield 2; yield … Read more

Why is `throw` invalid in an ES6 arrow function?

If you don’t use a block ({}) as body of an arrow function, the body must be an expression: ArrowFunction: ArrowParameters[no LineTerminator here] => ConciseBody ConciseBody: [lookahead ≠ { ] AssignmentExpression { FunctionBody } But throw is a statement, not an expression. In theory () => throw x; is equivalent to () => { return … Read more

Update one of the objects in array, in an immutable way

You can use map to iterate the data and check for the fieldName, if fieldName is cityId then you need to change the value and return a new object otherwise just return the same object. Write it like this: var data = [ {fieldName: ‘title’, valid: false}, {fieldName: ‘description’, valid: true}, {fieldName: ‘cityId’, valid: false}, … Read more

Importing javascript file for use within vue component

Include an external JavaScript file Try including your (external) JavaScript into the mounted hook of your Vue component. <script> export default { mounted() { const plugin = document.createElement(“script”); plugin.setAttribute( “src”, “//api.myplugincom/widget/mykey.js” ); plugin.async = true; document.head.appendChild(plugin); } }; </script> Reference: How to include a tag on a Vue component Import a local JavaScript file In … Read more

async await in image loading

Your problem here extends from the definition for await… The await operator is used to wait for a Promise The Image.prototype.onload property is not a promise, nor are you assigning it one. If you’re wanting to return the height property after loading, I would instead create a Promise… addImageProcess(src){ return new Promise((resolve, reject) => { … Read more

How to get the first element of Set in ES6 ( EcmaScript 2015)

They don’t seem to expose the List to be accessible from the instanced Object. This is from the EcmaScript Draft: 23.2.4 Properties of Set Instances Set instances are ordinary objects that inherit properties from the Set prototype. Set instances also have a [[SetData]] internal slot. [[SetData]] is the list of values the Set is holding. … Read more