Category "ecmascript-6"

Can ES6 template literals be substituted at runtime (or reused)?

tl;dr: Is it possible to make a reusable template literal? I've been trying to use template literals but I guess I just don't get it and now I'm getting frustr

Expected 'this' to be used by class method

In my class, eslint is complaining "Expected 'this' to be used by class method 'getUrlParams' Here is my class: class PostSearch extends React.Component { c

How to iterate over keys of a generic object in TypeScript?

I need to iterate over a large object which is just typed as "object". It contains an unknown number of objects of the same type. In older posts I had found so

const vs let when calling require

As io.js now supports ES6 you are finally able to use the const and let keywords. Obviously, let is the successor of var, just with some super-powers. But what

ES6 Modules : Importing a module in an Angular component

I have an ES6 module where I am exporting a library. I want to be able to use this module in an Angular component. I cannot have the library files locally withi

ES6 Modules : Importing a module in an Angular component

I have an ES6 module where I am exporting a library. I want to be able to use this module in an Angular component. I cannot have the library files locally withi

How to change swipe direction in swiper.js?

I'm struggling with changing swipe direction when I rotate my swiper on 90deg. So in the beginning by default it has horizontal direction. When clicking on sli

flatten nested object using lodash

flatten, flattenDeep or flattenDepth of lodash only accept array. How to flatten nested object? var data = { "dates": { "expiry_date": "30 sep 2018",

Rollup is importing util

I am building a library to be used to call api's I am using rollup to bundle all the files into one file, the issue is its adding this line import util from 'ut

Is Node.js worker_threads module truly threads or just processes with IPC?

Recent Node.js versions contain the new module worker_threads which is said to bring multi-threading to Node.js. However, it seems using processes underhood: ht

Defer execution for ES6 Template Literals

I am playing with the new ES6 Template Literals feature and the first thing that came to my head was a String.format for JavaScript so I went about implementing

Replace element at specific position in an array without mutating it

How can the following operation be done without mutating the array: let array = ['item1']; console.log(array); // ['item1'] array[2] = 'item2'; // array is mut

React: Updating state when state is an array of objects

I have an array of objects in state: this.state = { items: [ {id: 1, someattr: "a string", anotherattr: ""}, {id: 2, someattr: "another string", anot

Winston 3.0 colorize whole output on console

I am developing a Node.js application, using babel-cli as an ES6 transpiler and I am using Winston 3.0 as my logging service. Question: I want the whole output

Winston 3.0 colorize whole output on console

I am developing a Node.js application, using babel-cli as an ES6 transpiler and I am using Winston 3.0 as my logging service. Question: I want the whole output

React: Updating state when state is an array of objects

I have an array of objects in state: this.state = { items: [ {id: 1, someattr: "a string", anotherattr: ""}, {id: 2, someattr: "another string", anot

ES2015 import doesn't work (even at top-level) in Firefox

These are my sample files: <!DOCTYPE html> <html> <head> <title>Test</title> <script src="t1.js"></script> </h

How to test if an object is a Proxy?

I would like to test if a JavaScript object is a Proxy. The trivial approach if (obj instanceof Proxy) ... doesn't work here, nor does traversing the prototy

How to tell typescript, that process is not undefined?

In the following line of code: internalWhiteList = process.env.INTERNAL_IP_WHITELIST.split( ',' ) I get an error saying, Object is possibly undefined. env va

Template literals with nested backticks(`) in ES6

How can I write a template literal in ECMAScript 6 that will contain backticks(`) in and by itself, (i.e. nested backticks)? For example: var query = `