You have a list with website URLs with some mistakes — capital letters. Print the number of the list elements, fix the mistakes in each element of this list, make a map with the domains as key and the length of the respective URLs as value. Try to do it within the body of a proper scope function. Note: Don’t print the whole map, only return it.
es6-promise 27.86 KB (7.33 KB gzipped)es6-promise-auto 27.78 KB (7.3 KB gzipped) - Automatically provides/replaces Promise if missing or broken. es6-promise-min 6.17 KB (2.4 KB gzipped)es6-promise-auto-min 6.19 KB (2.4 KB gzipped) - Minified version of es6-promise-auto above.
CDN
1 2 3 4 5 6 7
<!-- Automatically provides/replaces `Promise` if missing or broken. --> <scriptsrc="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.js"></script> <scriptsrc="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.auto.js"></script>
<!-- Minified version of `es6-promise-auto` below. --> <scriptsrc="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.min.js"></script> <scriptsrc="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.auto.min.js"></script>
* About to connect() to api.gowhich.com port 443 (#1) * Trying 10.252.117.104... * Connected to api.gowhich.com (10.252.117.104) port 443 (#1) * Initializing NSS with certpath: sql:/etc/pki/nssdb * Unable to initialize NSS database * Initializing NSS with certpath: none * Unable to initialize NSS * Closing connection 1
错误信息2
1 2 3 4 5 6
* Initializing NSS with certpath: none * NSS error -5978 (PR_NOT_CONNECTED_ERROR) * Network file descriptor is not connected * Closing connection 0 int(35) Network file descriptor is not connected
$ git flow init Initialized empty Git repository in /Users/xxx/xxx-website/.git/ Branch name for production releases: [master] Branch name for"next release" development: [develop]
How to name your supporting branch prefixes? Feature branches? [feature/] Release branches? [release/] Hotfix branches? [hotfix/]
Error: i am a error at Object.<anonymous> (/Users/durban/nodejs/main.js:45:23) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Function.Module.runMain (internal/modules/cjs/loader.js:831:12) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3) Emitted 'error' event at: at Object.<anonymous> (/Users/durban/nodejs/main.js:45:9) at Module._compile (internal/modules/cjs/loader.js:778:30) [... lines matching original stack trace ...] at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
再看下面实例
1 2 3 4 5 6 7 8 9 10
constEventEmitter = require("events");
const emitter = newEventEmitter();
emitter.on("error", function (error) { console.log("i am catch a error"); console.log(error); });
emitter.emit("error", newError("i am a error"));
运行后结果如下
1 2 3 4 5 6 7 8 9 10 11 12
$ node main.js i am catch a error Error: i am a error at Object.<anonymous> (/Users/durban/nodejs/main.js:77:23) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Function.Module.runMain (internal/modules/cjs/loader.js:831:12) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)