- implement function
reverseString(str) - implement function
factorial(n) - implement function
removeFromArray(arr, arg1, arg2, ...)
- What will be the output of this:
| <script src="app.js"></script> | |
| <script src="OtherService.js"></script> | |
| <script src="MyService.js"></script> |
| language: node_js | |
| node_js: | |
| - "6" | |
| script: | |
| - npm run lint | |
| - npm run build | |
| - npm test |
When you try to add eslint to a large project, you better try this approach as in this script.
Now, you want to enforce your team members to actually remove the /* eslint-disable */ comment at file header, for all files that they've changed.
Here you go.
| { | |
| "name": "my-package", | |
| "version": "1.2.0", | |
| "scripts": { | |
| "patch-version": "node patch-version.js", | |
| "tag-version": "node tag-version.js \"release-tag\"", | |
| "prerelease": "npm run patch-version && npm run tag-version", | |
| "release": "npm publish", | |
| } | |
| } |
| const app = () => { | |
| const list = [] | |
| return { | |
| add: (item) => list.push(list), | |
| get: () => list.slice(0), | |
| } | |
| } | |
| module.exports = app |
| const sleep = ms => new Promise(res => setTimeout(()=>res(ms), ms)) | |
| // main1(); | |
| // main2(); | |
| // run(main3); | |
| run2(main3); | |
| function main1() { | |
| console.log(1); | |
| sleep(100).then(t => console.log(2, t)); |
| const proc = require('child_process'); | |
| const gitGetTag = cb => proc.execFile('git', ['describe', '--abbrev=0', '--tags'], (err, res) => cb(res.trim())); | |
| const gitPutTag = (tag, cb) => proc.execFile('git', ['tag', tag], (err, res) => cb(res.trim())); | |
| const parseTag = (tag) => { | |
| try { | |
| return /v(\d+)\.(\d+)\.(\d+)(-(\d+))?/.exec(tag).slice(1) | |
| } catch (e) { | |
| // do nothing |
| /** | |
| * https://jsfiddle.net/ronapelbaum/qk6mcrae/ | |
| */ | |
| // HOF get a func and returns a func | |
| function createFilterFunc(fn) { | |
| return function(arr) { | |
| const res = []; | |
| for(let i = 0; i < arr.length; i++) { | |
| if(!!fn(arr[i])) { | |
| res.push(arr[i]); |