You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
570 B
29 lines
570 B
|
5 years ago
|
#!/usr/bin/env node
|
||
|
|
const pathOr = require('ramda/src/pathOr');
|
||
|
|
let input = [];
|
||
|
|
|
||
|
|
// YOLO
|
||
|
|
let ids = eval(process.argv.slice(2).pop()).map((id) => `${id}`);
|
||
|
|
|
||
|
|
process.stdin.resume();
|
||
|
|
process.stdin.setEncoding('utf8');
|
||
|
|
|
||
|
|
process.stdin.on('data', (data) => {
|
||
|
|
input.push(data);
|
||
|
|
});
|
||
|
|
|
||
|
|
process.stdin.on('end', () => {
|
||
|
|
const str = input.join('');
|
||
|
|
const arr = JSON.parse(str);
|
||
|
|
|
||
|
|
const output = arr.reduce((acc, elem) => {
|
||
|
|
if (ids.includes(elem.id)) {
|
||
|
|
return acc;
|
||
|
|
} else {
|
||
|
|
return [...acc, elem];
|
||
|
|
}
|
||
|
|
}, []);
|
||
|
|
|
||
|
|
console.log(JSON.stringify(output));
|
||
|
|
});
|