Use this tag for questions about features finalized in ECMAScript 2017. Do *not* use this tag if the code in question merely *uses* one of the features, *unless* the feature is cause of the problem.
Consider the following object:
const test = {
foo: ['foo', 'bar', 'foobar'],
bar: ['foo', 'bar', 'foobar']
foobar: ['foo', 'bar', 'foobar']
};
How would one go about getting the combined count of all of the items within each of the…
I am trying to use async / await to do long computations on JavaScript on a browser. Should the code be changed or any improvements be done? It seems using promises may make it complicated. I also have two related questions at the end of the…
I am so confused about this. All I want to do is simply break up my javascript into modules, and include them in certain pages. Some pages may need my user-module.js , some pages may not.
I have Googled, read the tutorials, and it's still not…
Say I have the following:
const a = new A();
await a.getB().action();
A.prototype.getB() is async as-well as B.prototype.action().
If I try to await on the chaining of the functions I get an error:
TypeError: a.getB(...).action is not a…
I am struggling with async await try catch block for a couple of days.
async function executeJob(job) {
// necessary variable declaration code here
try {
do {
let procedureRequests = await ProcedureRequestModel.find(filter,…
I have encountered a change in the javascript function declaration that seems to be off. You can make a function like this:
let a = function (b,) {
console.log(b);
}
I have found that the trailing comma in function parameters is allowed because…
I'm going through the exercise of making my webpack bundle smaller, and using webpack's bundle analyzer I saw that a really heavy package is being included in two different async chunks, even though it's only used once. After some digging in my…
Using puppeteer to collect data from 2 different webpages into arrays for later comparison. However the program does not wait for the returned array before carrying forward.
async function go(){
try{
const browser = await puppeteer.launch();
…
So I have a function that should immediatly return a rejected or resolved Promise, i.e. it is basically a snychronous function I want to "promisify".
What I usually do in such cases is something like this:
func() {
// some code to check for an…
I'm using Mocha and Chai + ChaiHttp for testing my API. The problem I have is that I don't see any error messages when a expect statement is failing.
Here is my code:
it('POST /signup : should create a new user', async () => {
const user = {
…
I am currently migrating an old Firefox extension and want to use the es2017 features.
The dependencies:
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.4",
"babel-preset-env": "^1.6.1",
"babel-preset-es2017": "^6.24.1",
…
I assign two calls to the web service in two variables in referencesPromise and contactTypesPromise $onInit() (I can create a new method for that, if needed)
$onInit() {
const referencesPromise =…
I'm having trouble with async/await with Node. When I try this:
function Read_Json_File() {
fs.readFile('import.json','utf-8',(err, data) => {
if (err) throw err;
json_data = JSON.parse(data);
return json_data;
…
I am having an issue migrating below two functions from generators to async / await.
When I await the endPoints inside send(), I get the promise return value from fixedPublisher() as undefined.
Am I missing anything below ?
Generators:
export…
I try to use Jest with bablejs and ES2017 in my project, according to the Jest Getting Started page and also Bablejs config for ES2017 this is my .babelrc file :
{
"presets": ["es2017"],
"env": {
"test": {
"presets": ["es2017"]
}
…