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
). После этого нужные пункты оглавления подсветятся желтым и вы легко найдете нужный. function haveSameValues(arr1, arr2) {
if (arr1.length !== arr2.length) {
return false;
}
const count = new Map;
arr1.forEach(n => count.set(n, -~count.get(n)));
arr2.forEach(n => count.set(n, ~-count.get(n)));
for (const n of count.values()) if (n) {
return false;
}
return true;
}
haveSameValues(
[ 'hello, world!!', 0, 0, 0, 1, 1, false, false ],
[ false, false, 1, 1, 0, 0, 0, 'hello, world!!' ]
) // true
haveSameValues(
[ 1, 2, 3 ],
[ 3, 2, 2 ]
) // false
haveSameValues(
[],
[]
) // true
const areEqual = (arrA, arrB) => {
if (arrA.length !== arrB.length) return false;
const a = arrA.slice().sort(), b = arrB.slice().sort();
return a.every((el, i) => el === b[i]);
}
const areEqual = (arrA, arrB) => {
if (arrA.length !== arrB.length) return false;
const a = arrA.slice(), b = arrB.slice();
while (a.length) {
const i = b.indexOf(a.pop());
if (-1 === i) return false;
b.splice(i, 1);
}
return true;
}
type ValueOf<T> = T[keyof T];
const enum BlockType {
Paragpraph = 'PARAGRAPH',
Image = 'IMAGE',
List = 'LIST',
}
interface BodyTypes {
[BlockType.Paragpraph]: string;
[BlockType.Image]: File;
[BlockType.List]: string[];
}
interface IBlock<T extends BlockType> {
type: T;
body: BodyTypes[T];
}
type TBlock = ValueOf<{ [P in BlockType]: IBlock<P> }>;
// type TBlock = IBlock<BlockType.Paragpraph> | IBlock<BlockType.Image> | IBlock<BlockType.List>;
function x(b: TBlock) {
if (b.type === BlockType.Paragpraph) {
// b.body is string
} else if (b.type === BlockType.Image) {
// b.body is File
}
}
1. когда уместно использовать данный язык?
2. Можно ли использовать TS без фреймов и библиотек?
3. И есть ли смысл его использовать без фреймворков?
которая будет поднимать что-то вроде виртуального linux окружения на время обращения к .so.Windows Subsystem for Linux
use raylib::prelude::*;
fn main() {
let (mut rl, thread) = raylib::init()
.size(640, 480)
.title("Hello, World")
.build();
while !rl.window_should_close() {
let mut d = rl.begin_drawing(&thread);
d.clear_background(Color::WHITE);
d.draw_text("Hello, world!", 12, 12, 20, Color::BLACK);
}
}