ecmascript-6

JAVAFX 11 not supporting ECMAScript6 and css3

坚强是说给别人听的谎言 提交于 2021-01-28 19:00:00
问题 I am creating a web browsing exp with some drawing tool with JAVA FX 11 but while trying to load the javascript code which has let and const used these variables are simply getting ignored and throwing the exceptions. I am using maven 3.8.0, Java 1.8 and JavaFX 11. The code is as follows: <dependency> <groupId>org.openjfx</groupId> <artifactId>javafx-controls</artifactId> <version>12-ea+9</version> </dependency> <dependency> <groupId>org.openjfx</groupId> <artifactId>javafx-web</artifactId>

Typescript | Call a function every time a function is called

自作多情 提交于 2021-01-28 11:09:59
问题 I am trying to write a Typescript API service. For the service I need a way to check that the method exists when a function such as get is called. I realise I can do like get(endpoint: string) { this.handleRequest(); } post(endpoint: string, data: any) { this.handleRequest(); } But I don't particularly want to do that are the top of every method so I didn't know if there was a way to listen within the constructor of the Typescript class for a call of a child function. It seems a little far

Typescript | Call a function every time a function is called

风流意气都作罢 提交于 2021-01-28 11:03:06
问题 I am trying to write a Typescript API service. For the service I need a way to check that the method exists when a function such as get is called. I realise I can do like get(endpoint: string) { this.handleRequest(); } post(endpoint: string, data: any) { this.handleRequest(); } But I don't particularly want to do that are the top of every method so I didn't know if there was a way to listen within the constructor of the Typescript class for a call of a child function. It seems a little far

rest operator to omit properties

寵の児 提交于 2021-01-28 09:51:56
问题 I'm attempting to use the rest operator and restructuring to omit an entry in the object. Based on the documentation, rest should no longer include the key entry 575. After the operation, rest still has the same keys as state. I'm not sure what I'm doing wrong. Thanks in advance. book = { id: 575, title: "Vector Calc" }; state = { removedBooks: { 46: { id: 46, title: "economics" }, 575: { id: 575, title: "Vector Calc" } } }; const { [book.id]: data, ...rest } = state; console.log(rest); EDIT:

How to use javascript promises ES6 instead of jQuery ajax call?

感情迁移 提交于 2021-01-28 08:11:47
问题 I was trying to understand how promises works in javascript but I didn't found clear info about this, I would like to know if it possible and it is so how to do this using promises instead this code (equivalent) $.ajax({ type: 'post', cache: false, url: 'myfile.php', data: { info: info }, datatype: 'json', success: function(response) { console.log(response); } }); I ask this because I want to use only javascript without any framework or plugins, I have no problem with the other new feautures

Array not reseting in Node.js

依然范特西╮ 提交于 2021-01-28 08:09:53
问题 I am running a Node+Express API that is working quite well, the only problem I have is when returning a complex query as a response, the variable to which I set the response to is not getting reset between requests. It duplicates replies to the client such as replying 1, 2, 3 then the next reply replies 1, 2, 3, 1, 2, 3. So basically, it's concatenating data and not setting the allPosts variable to null again. Here is my code: var allPosts = []; chirprdb.allPosts = (userData) => { return new

Sort mixed alpha/numeric Array in javascript

杀马特。学长 韩版系。学妹 提交于 2021-01-28 07:02:56
问题 I have a mixed array that I need to sort by digit and then by alphabet var x = ['1','2A','2B','2AA','2','10A','10','11','12A','12B','12'] Desired Output sortedArray = ['1','2','2A','2B','2AA','10','10A','11','12','12A','12B'] I had tried using lodash but wasn't getting desired result var x = ['1','2A','2B','2AA','2','10A','10','11','12A','12B','12'] _.sortBy(x); //lodash result ["1", "10", "10A", "11", "12", "12A", "12B", "2", "2A", "2AA", "2B"] 回答1: You can use parseInt to get the number

Creating class with vm.runInNewContext (forcing class expression instead of class declaration in ES6)

纵饮孤独 提交于 2021-01-28 06:27:09
问题 I am debugging another person's package (currently unmaintained) that runs in the Atom editor. At one point, this package uses vm.runInContext to define a class object, using code equivalent to the following: const vm = require('vm') myClass = vm.runInNewContext('class x {}', {}, 'file') I think this code runs in node.js , but I don't really know all the details of Atom's javascript environment. At any rate, I'm pretty sure it's running in ES6 or later. I believe that when this package was

How to achieve the spread operator in IE 11?

我们两清 提交于 2021-01-28 06:25:36
问题 For some " extraction " operation I am trying to get the following snippet work, without using the spread operator, because IE 11 doesn't knows about spread operators. works in Chrome, but not IE 11: html_col_width =[{"targets":0, "width":50}, {"targets":1, "width":100},{"targets":2, "width":442}] ... some other code order: [ [response.order_by_column, response.order_by] ], columnDefs: [ ...html_col_width, {other: stuff}, {other: stuff} }) See columnDefs: ...html_col_width How can I achieve

How to create function that returns mixin function in TypeScript?

◇◆丶佛笑我妖孽 提交于 2021-01-28 06:00:11
问题 I try to convert Polymer.dedupingMixin ES6 function to TypeScript. I don't sure it's possible or not. https://github.com/Polymer/polymer/blob/v2.0.2/lib/utils/mixin.html Normally, TypeScript 2.2+ can work correctly for basic mixin function like the following code. type IConstructable = new (...args: any[]) => object; function extendClass<T extends IConstructable>(baseClass: T) { return class extends baseClass { instanceMethod_DynamicClass() { } static staticMethod_DynamicClass() { } } } class