- Apr 2024
-
developer.mozilla.org developer.mozilla.org
- Nov 2023
-
flaviocopes.com flaviocopes.com
-
```js import path from 'path'; import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); ```
Tags
Annotators
URL
-
- Jul 2023
-
Tags
Annotators
URL
-
- Mar 2023
-
nodesource.com nodesource.com
-
exploringjs.com exploringjs.com
-
-
Streaming across worker threads
```js import { ReadableStream } from 'node:stream/web'; import { Worker } from 'node:worker_threads';
const readable = new ReadableStream(getSomeSource());
const worker = new Worker('/path/to/worker.js', { workerData: readable, transferList: [readable], }); ```
```js const { workerData: stream } = require('worker_threads');
const reader = stream.getReader(); reader.read().then(console.log); ```
-
Consuming web streams
```js import { arrayBuffer, blob, buffer, json, text, } from 'node:stream/consumers';
const data1 = await arrayBuffer(getReadableStreamSomehow());
const data2 = await blob(getReadableStreamSomehow());
const data3 = await buffer(getReadableStreamSomehow());
const data4 = await json(getReadableStreamSomehow());
const data5 = await text(getReadableStreamSomehow()); ```
-
Adapting to the Node.js Streams API
```js /* * For instance, given a ReadableStream object, the stream.Readable.fromWeb() method * will create an return a Node.js stream.Readable object that can be used to consume * the ReadableStream's data: / import { Readable } from 'node:stream';
const readable = new ReadableStream(getSomeSource());
const nodeReadable = Readable.fromWeb(readable);
nodeReadable.on('data', console.log); ```
```js /* * The adaptation can also work the other way -- starting with a Node.js * stream.Readable and acquiring a web streams ReadableStream: / import { Readable } from 'node:stream';
const readable = new Readable({ read(size) { reader.push(Buffer.from('hello')); } });
const readableStream = Readable.toWeb(readable);
await readableStream.read();
```
Tags
Annotators
URL
-
-
Tags
Annotators
URL
-
-
2ality.com 2ality.com
- Feb 2023
-
-
Node.js
js import { renderToPipeableStream } from "react-dom/server.node"; import React from "react"; import http from "http"; const App = () => ( <html> <body> <h1>Hello World</h1> <p>This is an example.</p> </body> </html> ); var didError = false; http .createServer(function (req, res) { const stream = renderToPipeableStream(<App />, { onShellReady() { res.statusCode = didError ? 500 : 200; res.setHeader("Content-type", "text/html"); res.setHeader("Cache-Control", "no-transform"); stream.pipe(res); }, onShellError(error) { res.statusCode = 500; res.send( '<!doctype html><p>Loading...</p><script src="clientrender.js"></script>', ); }, onAllReady() { }, onError(err) { didError = true; console.error(err); }, }); }) .listen(3000);
Deno
```js import { renderToReadableStream } from "https://esm.run/react-dom/server"; import * as React from "https://esm.run/react";
const App = () => ( <html> <body>
Hello World
This is an example.
</body> </html> );const headers = { headers: { "Content-Type": "text/html", "Cache-Control": "no-transform", }, };
Deno.serve( async (req) => { return new Response(await renderToReadableStream(<App />), headers); }, { port: 3000 }, ); ```
Bun
```js import { renderToReadableStream } from "react-dom/server"; const headers = { headers: { "Content-Type": "text/html", }, };
const App = () => ( <html> <body>
Hello World
This is an example.
</body> </html> );Bun.serve({ port: 3000, async fetch(req) { return new Response(await renderToReadableStream(<App />), headers); }, }); ```
-
-
beta.reactjs.org beta.reactjs.org
-
nodejs.org nodejs.org
-
-
webcontainers.io webcontainers.io
Tags
Annotators
URL
-
-
sandpack.codesandbox.io sandpack.codesandbox.io
Tags
Annotators
URL
-
-
Tags
Annotators
URL
-
- Dec 2022
-
www.zhihu.com www.zhihu.com
-
大厂用node解决什么需求?
Tags
Annotators
URL
-
-
www.zhihu.com www.zhihu.com
-
你用 Node.js 写过哪些大型/复杂的应用?碰到什么难点?
Tags
Annotators
URL
-
- Sep 2022
-
nodejs.dev nodejs.dev
-
- Aug 2022
-
nodejs.org nodejs.org
Tags
Annotators
URL
-
- Jun 2022
-
fosstodon.org fosstodon.org
-
I have one Gatsby site left that I haven't touched in years, I doubt it will get past npm install.
-
- May 2022
-
news.ycombinator.com news.ycombinator.com
-
I develop in Node and Sveltekit regularly and the chances that on any given day my flow might be crushed by random madness is unacceptably high.
Tags
Annotators
URL
-
-
news.ycombinator.com news.ycombinator.com
-
every time i run npm install i am prepared to embark on a bunch of side missions.
-
-
news.ycombinator.com news.ycombinator.com
-
Not only this. Try to change the app two years later. Dependencies gone, wrong NPM version, Webpack config depricated and what not.That's why I like to use vanilla JS as much as possible. It will be maintainable years later.
-
-
blog.cloudflare.com blog.cloudflare.com
-
To address this issue, and to make it easier for non-web browser environments to implement fetch in a consistent way, WinterCG is working on documenting a subset of the fetch standard that deals specifically with those different requirements and constraints.
Tags
Annotators
URL
-
- Jan 2022
- Dec 2021
-
github.com github.com
Tags
Annotators
URL
-
-
dev.to dev.to
-
npm init -y \ && npm i --save-dev node@16 \ && npm config set prefix=$(pwd)/node_modules/node \ && export PATH=$(pwd)/node_modules/node/bin:$PATH
Tags
Annotators
URL
-
-
httptoolkit.tech httptoolkit.tech
Tags
Annotators
URL
-
- Nov 2021
-
www.stefanjudis.com www.stefanjudis.com
-
import { createRequire } from "module"; const require = createRequire(import.meta.url); const data = require("./data.json");
-
- Oct 2021
-
www.sitepoint.com www.sitepoint.com
-
blog.logrocket.com blog.logrocket.com
- Jan 2021
-
nodejs.org nodejs.org
-
Buffers and TypedArrays
Uint8Array is a type of TypedArray
and Buffer is an instance of Uint8Array
Creating TypedArrays from Buffer with or without sharing same memory.
Creating a Buffer from the TypedArrays with or without sharing the same memory
In order to share memory we use
- Buffer.buffer, Buffer.byteOffset, Buffer.length / TypedArray.BYTES_PER_ELEMENT
- TypedArray.buffer, offset, length
-
- Apr 2020
-
medium.com medium.com
- Dec 2019
-
nodesource.com nodesource.com
Tags
Annotators
URL
-
-
stackoverflow.com stackoverflow.com
-
You have to create duplicate of the stream by piping it to two streams. You can create a simple stream with a PassThrough stream, it simply passes the input to the output.
-
-
node.green node.green
-
- Sep 2019
-
advancedweb.hu advancedweb.hu
-
- Jun 2019
-
jscomplete.com jscomplete.com
Tags
Annotators
URL
-
- Nov 2018
-
www.iglobsyn.com www.iglobsyn.com
-
Best Nodejs development company
-
-
www.apsense.com www.apsense.com
-
Develop a Lightweight Project With the Help of AWS, Lambda and Serverless
Develop a Lightweight Project With the Help of AWS, Lambda and Serverless
-
- Oct 2018
-
blog.programster.org blog.programster.org
-
boilerplate
-
- Sep 2018
-
javascript.ruanyifeng.com javascript.ruanyifeng.com
-
module.exports属性表示当前模块对外输出的接口,其他文件加载该模块,实际上就是读取module.exports变量。
也就是说:
require
获得的是module.export
对象;export === modue.export
指向同一块内存;export
是一个快捷方式,覆盖就没有意义;module.export
可以覆盖,这取决与需要暴露什么对象或方法;覆盖后export
无效,因为 第 1 条;
-
- Jun 2018
-
developer.mozilla.org developer.mozilla.org
-
The next set of functions call app.use() to add the middleware libraries into the request handling chain
This is how you'd add middlewares!
-
Then we require() modules from our routes directory
Routes are also a module. This 'module' is nothing more than a way to 'include' other file, so to speak in PHP terms. Its the ability to split code/functionality across multiple manageable files
-
- Apr 2018
-
www.tomas-dvorak.cz www.tomas-dvorak.cz
- Nov 2017
-
-
install nodejs
-
- Jan 2016
-
schempy.com schempy.com
- Jun 2015
-
nodeschool.io nodeschool.io
-
stream-adventure
Some overlap with learnyounode and fewer instructions, I think this is one of the first ones that was created. Still nice to really dig into streams which are an important concept to understand.
-
learnyounode
This one's really well done, I recommend starting here if you already have some JS experience.
-
Right now there's no good way (that I know of) to keep track of new workshoppers (the little interactive workshops that you can run on your own), so I occasionally check https://github.com/nodeschool/nodeschool.github.io (the code of the website) for commits.
-
- May 2015
-
www.hostingadvice.com www.hostingadvice.com
-
Top 5 Free Node.js Hosting Services
Ücretsiz web uygulaması ve nodejs barındırılabilecek hizmet sağlayıcılar
-
- Jan 2014
-
www.quora.com www.quora.com
-
What are the some of the challenges that we are going to face in the next 5 years?
Interesting analysis of Node.js's possible strengths.
-
-
substack.net substack.net
-
node aesthetic.
Read for reference on Node.js conventions
Tags
Annotators
URL
-