Мне лично на ум приходит такие как VBA
// если уверены, что длины всех массивов будут равны
const zip = arrs => arrs[0]?.map((n, i) => arrs.map(m => m[i])) ?? [];
// или, вместо отсутствующих значений подставляем какое-то дефолтное
const zip = (arrs, defaultValue = null) => Array.from(
{ length: Math.max(...arrs.map(n => n.length)) },
(n, i) => arrs.map(m => i < m.length ? m[i] : defaultValue)
);
// или
const zip = (arrs, defaultValue = null) =>
arrs.reduce((acc, n, i) => (
n.forEach((m, j) => (acc[j] ??= Array(arrs.length).fill(defaultValue))[i] = m),
acc
), []);
const arr = zip([ arr1, arr2 ]);
. function call<R>(f: () => R): R {
return f()
}
class Result<T>{
public readonly result;
constructor(result: T){
this.result = result;
}
}
class NumberResult extends Result<number>{
constructor(result: number){
super(result);
}
public ResultPlusOne(){
return this.result + 1;
}
}
Result<T>
- это открытый дженерик, то есть в будущем на месте T должен быть указан другой\типы или типы для того чтобы создавать экземпляры класса.let result = new Result<number>(42)
class Result{
public readonly result;
constructor(result: number){
this.result = result;
}
}
class NumberResult extends Result<number>
class Base<T> {
protected val: T;
}
class A extends Base<string> {
methodA(): string {
return this.val; // Ok, так как здесь val имеет тип string
}
}
class B extends Base<number> {
methodB(): number {
return this.val; // тоже ok, так как здесь val имеет тип number
}
}
fs.writeFile(file, data[, options], callback)#
History:
- file
<string> | <Buffer> | <URL> | <integer>
filename or file descriptor- data
<string> | <Buffer> | <TypedArray> | <DataView> | <Object>
- options
<Object> | <string>
- encoding
<string> | <null>
Default: 'utf8'- mode
<integer>
Default: 0o666- flag
<string>
See support of file system flags. Default: 'w'.- signal
<AbortSignal>
allows aborting an in-progress writeFile- callback
<Function>
- err
<Error> | <AggregateError>
When file is a filename, asynchronously writes data to the file, replacing the file if it already exists. data can be a string or a buffer.
When file is a file descriptor, the behavior is similar to calling fs.write() directly (which is recommended). See the notes below on using a file descriptor.
The encoding option is ignored if data is a buffer.
If data is a plain object, it must have an own (not inherited) toString function property.
...
fs.write
). После этого нужные пункты оглавления подсветятся желтым и вы легко найдете нужный. document.querySelector('.case-print')
type CreatureBasis = {
People: {
child: {
age: number;
school: string;
};
adult: {
age: number;
height: number;
weight: number;
};
};
Animal: {
fish: {
waterBody: string;
};
cat: {
catchMouses: boolean;
};
};
};
type Creature = {
[K0 in keyof CreatureBasis]: {
[K1 in keyof CreatureBasis[K0]]: {
type: K0;
subtype: K1;
params: CreatureBasis[K0][K1];
};
}[keyof CreatureBasis[K0]];
}[keyof CreatureBasis];