const { debounce } = require('lodash');
debounce(
() => {
console.log('testing..');
},
1000,
{ leading: true, trailing: false }
);
Run Code Online (Sandbox Code Playgroud)
上面的代码不起作用.
https://lodash.com/docs/4.17.4#debounce
文档中的所有示例都使用命名函数.
使用Loash debounce与匿名函数有问题吗?
例如...(这失败了)
\n\nconst currencyMap = {\r\n "$": "USD",\r\n "\xe2\x82\xac": "EUR",\r\n};\r\n\r\nconst r = \'$100\'.replace(/(\\$)([0-9]*)/g, `${currencyMap[$1]}$2`);\r\nconsole.log(r);Run Code Online (Sandbox Code Playgroud)\r\n有没有办法让这种事情起作用? \n$1在字符串中使用时可用,但不能用作键。
每次我运行这个脚本时都会超时。是否setDefaultNavigationTimeout真正避免超时?
我浏览了大约 26 个 URL,每个页面都有大量图像。无法想象 Puppeteer 仅仅因为图片太重而无法处理这些页面?
const url = 'test.com';
const jsonReturn = [];
async function runScraper() {
const browser = await puppeteer.launch(prodConfig);
const page = await browser.newPage({
timeout: 0
});
page.setDefaultNavigationTimeout(0);
await page.goto(url, { waitUntil: 'domcontentloaded' });
await page.waitForSelector('.featured-shows-featured-show');
let featuredShowsURLs = await page.$$eval('.featured-shows-featured-show > a', (links) => {
return links.map(link => {
return link.href;
});
});
featuredShowsURLs = _.uniq(featuredShowsURLs)
for (const featuredShowsURL of featuredShowsURLs) {
const page = await browser.newPage({
timeout: 0
});
try { …Run Code Online (Sandbox Code Playgroud) 有没有办法捕获 Javascript 类方法中的所有异常?
class Foo {
method1() {}
method2() {}
methodToCatchAllError() {}
}
Run Code Online (Sandbox Code Playgroud)
并处理该类的本地异常?
rescue_from在 Ruby 中以类似的方式工作
以下是我执行时的终端输出tsc --version。
tsc --version
// Output: Version 3.8.3
Run Code Online (Sandbox Code Playgroud)
我没有在状态栏中看到 TypeScript“版本”。
从命令面板中选择 TypeScript 版本只是空白。
没有获得 Typescript 的任何 Intellisense。
我怎样才能让它发挥作用?
我有一个需要孩子的 React 组件。
收到 Typescript 错误:
Property 'children' is missing in type ... but required in type 'FixedWidthLayout'
该组件的定义类似于函数语句。
export default function FixedWidthLayout { ... }
我不想写像和表达..
IE
export const FixedWidthLayout = () => {...}
因此,做一些像...
const FixedWidthLayout: React.FC<Props> = () => {...}
..不是一个选择。
如何通过函数语句在 Typescript 中实现此功能?
为什么使用 Truffle 部署到主网如此困难?
这是尝试部署到主网的概述......
110000000000 wei让我们插上它..
mainnet: {
provider: () =>
new HDWalletProvider({
mnemonic: { phrase: process.env.MNEMONIC },
providerOrUrl: process.env.RPC_URL_1_WSS,
}),
network_id: 1,
from: process.env.DEPLOYERS_ADDRESS,
gasPrice: 110000000000, /* GAS PRICE!! */
confirmations: 2,
timeoutBlocks: 200,
skipDryRun: false, public nets )
},
},
Run Code Online (Sandbox Code Playgroud)
gas参数中设置truffle-config。NODE_ENV=production truffle migrate --network mainnet --dry-run
Summary
=======
> Total deployments: 2
> Final cost: 0.001403824 ETH
Run Code Online (Sandbox Code Playgroud)
0.001403824 ETH 是 2.04 美元。
所以这很可能是错误的。
??失败?? …
这是global.d.ts
interface Window {
routes: any;
routeMaker: any;
store: any;
searchKey: string;
}
Run Code Online (Sandbox Code Playgroud)
据我了解,任何事物global.d.ts本质上都是一样的
declare global {
interface Window {
routes: any;
routeMaker: any;
store: any;
searchKey: string;
}
}
Run Code Online (Sandbox Code Playgroud)
坐在根目录中,是tsconfig.json我指向的定义文件。
{
"compilerOptions": {
"target": "es6",
"declaration": false,
"emitDecoratorMetadata": true,
"baseUrl": ".",
"experimentalDecorators": true,
"lib": ["es6", "dom", "webworker"],
"module": "es6",
"moduleResolution": "node",
"sourceMap": true,
"jsx": "react",
"typeRoots": ["node_modules/@types", "types"],
"types": ["node", "webpack-env"],
"downlevelIteration": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true
},
"exclude": ["**/*.spec.js", "node_modules", "vendor", "public"],
"include": …Run Code Online (Sandbox Code Playgroud) 链中的所有函数都async/await必须使用async/await关键字吗?
async function one() {
return await fetch(.....);
}
async function two() {
return await one();
}
async function three() {
return await two();
}
Run Code Online (Sandbox Code Playgroud)
我在教程中看到了一些示例,其中调用者不必使用关键字。
在 VSCode 中使用Prettier扩展。
设置Single Quote为单人。
format onSave设置为 true。
还是... 当我点击保存时,单引号会转换为双引号..
为什么?为什么?为什么?为什么?
此外...
// in .eslint file
"quotes": [2, "single", { "avoidEscape": true }],
Run Code Online (Sandbox Code Playgroud)
还是... 当我点击保存时,单引号会转换为双引号..
javascript ×5
typescript ×3
async-await ×1
ethereum ×1
lodash ×1
prettier ×1
puppeteer ×1
reactjs ×1
regex ×1
truffle ×1