Monotonically increasing time in JavaScript?
You could use window.performance.now() – since Firefox 15, and window.performance.webkitNow() – Chrome 20] var a = window.performance.now(); //… var delay = window.performance.now() – a;
You could use window.performance.now() – since Firefox 15, and window.performance.webkitNow() – Chrome 20] var a = window.performance.now(); //… var delay = window.performance.now() – a;
Add the following line in addition to your current bodyParser app.use() right before: app.use(bodyParser.json()); This will enable bodyParser to parse content type of application/json. Hopefully that helps!
This is because of HTML link rewriting of Angular, explained here. To prevent rewriting of location, add target=_self to those bootstrap links. So instead of <a href=”#myModal”> you need <a href=”#myModal” target=”_self”>
This is a confusing design choice in TypeScript. In the short term you can work around it by specifying the output file: in main.ts specify the .js extension and path: import { testText } from ‘./module1.js’; alert(testText); This will pick up module.ts correctly, but output with the .js extension included. Note that you also need … Read more
The event loop is, first and foremost, a high-level concept that’s a fundamental part of the JavaScript programming model. Practically, every V8 embedder needs to implement an event loop. V8 provides a default implementation, which embedders can replace or extend. I don’t understand the question. (I guess the answer is “yes”, but what’s the difference … Read more
Jest has clearly addressed how to mock a module in this link https://jestjs.io/docs/en/manual-mocks#mocking-node-modules. It has an important note as following: Note: In order to mock properly, Jest needs jest.mock(‘moduleName’) to be in the same scope as the require/import statement. On the other hand, Most of use cases jest.mock is supposed to be called at the … Read more
You can use emscripten to generate fairly minimal code output. Consider the following trivial file adder.c: int adder (int a, int b) { return a + b; } Compile it like this (requires a fairly recent emscripten): emcc -O2 -s WASM=1 -s SIDE_MODULE=1 -o adder.wasm To see what it generated, disassemble it to wast textual … Read more
After more searching it turned out that I’m not the only one confused about how to use this option correctly. Issues from the GitHub repo of css-loader: https://github.com/webpack-contrib/css-loader/issues/765 Also see @guidobouman excellent explanation here: https://github.com/webpack-contrib/css-loader/issues/228#issuecomment-312885975 So this answers my question (quoted literally): importLoaders only has effect on unresolved @imports. So when using postCSS with nextCSS … Read more
File that exports a constant value that I want to mock: // utils/deviceTypeUtils file import DeviceInfo from ‘react-native-device-info’; export const isTablet = DeviceInfo.isTablet(); In my test file, I use this code to mock the constant isTablet: // file: deviceTypeUtils.spec const DeviceTypeUtilsMock = jest.requireMock(‘../utils/deviceTypeUtils’); jest.mock(‘../utils/deviceTypeUtils’, () => ({ isTablet: false, })); describe(‘mock const example’, () => … Read more
You can fix it like this: const data = await page.$eval(selector, node => (node as HTMLElement).innerText); or: const data = await page.$eval(selector, node => (<HTMLElement>node).innerText); UPDATE: So, after some exchange on Github, it’s clear why the syntax from this question does not work. It actually defines anonymous generic function. <HTMLElement>(node: HTMLElement) => node.innerText Clearer example … Read more