const data3 = [
{ x: 1, y: 2, z: 3 },
{ x: 4, y: 5, z: 6 },
{ x: 7, y: 8, z: 9 },
];
const changeKeyses = (arr, new_keyses) => arr.map(obj => {
Object.keys(obj).forEach((key, i) => {
let new_key = new_keyses[i];
if (new_key !== undefined) {
let val = obj[key];
delete obj[key];
obj[new_key] = val;
}
});
return obj;
});
console.log(changeKeyses(data3, ["a", "b", "c"]));
console.log(changeKeyses(data3, ["a", "b"]));
console.log(changeKeyses(data3, ["a"]));
const something = async _ => new Promise(resolve => setTimeout(resolve, 100));
const asyncRecursive = async (limit, count = 0) => {
await something();
console.log(count);
count+=1;
if (count < limit) {
await asyncRecursive(limit, count);
}
}
let limit = 10;
(async function() {
for(let n of Array.from(Array(limit).keys())) {
await something();
console.log(n);
}
await asyncRecursive(limit);
})();
A workspace is a set of packages that share the same Cargo.lock and output directory.
cargo build -p kernel --target x86_64-unknown-none
https://metanit.com/web/nodejs/