- implement function
reverseString(str)
- implement function
factorial(n)
- implement function
removeFromArray(arr, arg1, arg2, ...)
- What will be the output of this:
language: node_js | |
node_js: | |
- "6" | |
script: | |
- npm run lint | |
- npm run build | |
- npm test |
/** | |
* https://dev.to/coderbyte/a-common-coding-interview-question-461f | |
* https://jsfiddle.net/ronapelbaum/yLkbg4v1/ | |
*/ | |
function sol1(arr1, arr2) { | |
// O(n*m) | |
return arr1.filter(d => arr2.includes(d)); | |
} | |
function sol2(arr1, arr2) { |
/** | |
* 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]); |
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 |
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 app = () => { | |
const list = [] | |
return { | |
add: (item) => list.push(list), | |
get: () => list.slice(0), | |
} | |
} | |
module.exports = app |
{ | |
"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", | |
} | |
} |
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.