This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { parentPort } = require('worker_threads'); | |
| let b = 0; | |
| for (let i = 0; i < 1000; i++) { | |
| b += i; | |
| } | |
| parentPort.postMessage(b); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { Worker } = require('worker_threads'); | |
| const path = require('path'); | |
| const worker1 = new Worker(path.resolve('./worker.js')); | |
| worker1.on('message', (message) => { | |
| console.log('main thread get message', message); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| state = { | |
| list: [] | |
| }; | |
| clickBtn = () => { | |
| this.state.list.push({ | |
| id: Math.random(), | |
| name: randomStr.generate(4) | |
| }); | |
| this.setState(this.state); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const ele = document.querySelector('body > div.hero > div > div.test-wrapper.ng-scope > div'); | |
| let flag = true; | |
| const mouseDownEvent = document.createEvent('MouseEvents'); | |
| mouseDownEvent.initEvent('mousedown', true, true); | |
| const observer = new MutationObserver((mutations) => { | |
| mutations.every((mutation) => { | |
| if(mutation.target.classList.contains('view-go') && flag){ | |
| ele.dispatchEvent(mouseDownEvent); | |
| flag = false; | |
| return false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const mouseDownEvent = document.createEvent('MouseEvents'); | |
| mouseDownEvent.initEvent('mousedown', true, true); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MsgItem extends React.PureComponent { | |
| render() { | |
| return <li style={{ margin: "10px" }}> {this.props.msg} </li>; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component } from 'react'; | |
| class MsgItem extends Component { | |
| render() { | |
| return <li style={{ margin: "10px" }}> {this.props.msg} </li>; | |
| } | |
| } | |
| export default class App extends Component { | |
| state = { messages: [] } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const path = require('path'); | |
| const HtmlWebPackPlugin = require("html-webpack-plugin"); | |
| module.exports = { | |
| module: { | |
| rules: [ | |
| { | |
| test: /\.js$/, | |
| exclude: /node_modules/, | |
| use: ['babel-loader'] | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <html ⚡> | |
| <head> | |
| <meta charset="utf-8"> | |
| <script async src="https://cdn.ampproject.org/v0.js"></script> | |
| <title>Hello AMP world</title> | |
| <link rel="canonical" href="hello-world.html"> | |
| <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"> | |
| <style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-anim |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const selectSize = (size) => { | |
| const selector = document.querySelector('#exp-pdp-buying-tools-container > form > div.exp-pdp-size-and-quantity-container > div > div.exp-pdp-size-dropdown-container.nsg-form--drop-down--option-container.selectBox-options.nsg-form--drop-down.exp-pdp-size-dropdown.exp-pdp-dropdown.two-column-dropdown.selectBox-dropdown-menu > ul'); | |
| const children = Array.from(selector.children); | |
| children.forEach(ele => { | |
| const rel = ele.getAttribute('rel'); | |
| if (rel.substring(rel.indexOf(':'), rel.length) === `:${size}`) { | |
| console.log('find ele', ele); | |
| $('select[name="skuAndSize"]').val(rel); | |
| $('#buyingtools-add-to-cart-button').click(); | |
| } |