Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
244 commits
Select commit Hold shift + click to select a range
6018f64
chore(next.js): added initial package.json update and configuration f…
ovflowd Jan 3, 2023
0e658ac
chore(static): moved static files to public/static
ovflowd Jan 3, 2023
72305ce
chore(pages): moved locale directory to pages/
ovflowd Jan 3, 2023
46f20c2
chore(survey): added readme and updated deploy script for survey
ovflowd Jan 3, 2023
2cc4263
chore(legacy): removed build.js and server.js
ovflowd Jan 3, 2023
5016948
chore(typescript): updated theme.tsx and added typescript support
ovflowd Jan 3, 2023
1655c58
chore(folder-structure): continued moving files and clean up of things
ovflowd Jan 3, 2023
60110f6
chore(codeowners): updated codeowners
ovflowd Jan 3, 2023
94de20d
chore(eslint): updated markdown matching
ovflowd Jan 3, 2023
d725521
chore(move): moved styles and layout and data folders
ovflowd Jan 7, 2023
0857c35
chore(i18n): added initial locale config
ovflowd Jan 7, 2023
556a5e9
chore(lts): stick with v18 lts
ovflowd Jan 7, 2023
f6264d7
chore(i18n): updated crowdin configuration
ovflowd Jan 7, 2023
edd70c6
chore(lts): fixed lts naming on ci and nvm
ovflowd Jan 7, 2023
c8e35ba
chore(package.json): fixed lint commands
ovflowd Jan 7, 2023
8cd5490
chore(package-lock): reindexed and updated package lock
ovflowd Jan 7, 2023
e7dccb0
chore(i18n): added react-intl package
ovflowd Jan 7, 2023
f013a23
chore(configs): updated next, eslint and tsconfig
ovflowd Jan 7, 2023
a7dca8f
chore(packages): add prettier config for the plugin
ovflowd Jan 7, 2023
d3c862c
chore(configs): updated prettier, eslint adn package.json
ovflowd Jan 7, 2023
1da23b8
chore(package): removed airbnb config
ovflowd Jan 7, 2023
353e897
chore(lint): applied linting in core files
ovflowd Jan 7, 2023
96a74c7
chore(lint): applied linting on markdown and style files
ovflowd Jan 7, 2023
2f636af
chore(ci): disable build job for now
ovflowd Jan 7, 2023
fb76c10
chore(cache): added eslint cache files to ignore
ovflowd Jan 7, 2023
c77e2b9
chore(public): moved robots and security to root public folder
ovflowd Jan 7, 2023
16bd72e
chore(eslint): added default next config
ovflowd Jan 7, 2023
d78ab95
chore(remark): added remark configuration
ovflowd Jan 7, 2023
afaa644
chore(i18n): added ICU locale files boilerplates
ovflowd Jan 9, 2023
5c0817a
chore(config): added website config file
ovflowd Jan 9, 2023
2c94964
chore(favicon): removed all favicon alternates to a simple png file
ovflowd Jan 9, 2023
1866ede
chore(dependencies): added a rss/atom/json feed package
ovflowd Jan 9, 2023
641b33e
chore(packages): updated packages and adopted npm-run-all
ovflowd Jan 9, 2023
a3277cf
chore(layouts): removed blm specific layouts
ovflowd Jan 9, 2023
7c509cb
feast(config): introduced site config provider and context
ovflowd Jan 9, 2023
bcc3521
feat(header): started to create the header component
ovflowd Jan 9, 2023
2168b76
chore(provider): refactored provider
ovflowd Jan 9, 2023
2a4d883
chore(fonts): added source sans pro font
ovflowd Jan 9, 2023
fec974c
feat(templates): added core component
ovflowd Jan 9, 2023
930aaad
chore(pages): removed legacy blm page
ovflowd Jan 9, 2023
c7d8ead
feat(types): introduced frontmatter types
ovflowd Jan 9, 2023
c3d2b00
chore(theme): started to update theme with layout
ovflowd Jan 9, 2023
9d28216
feat(config): updated site config types
ovflowd Jan 9, 2023
00d07c6
feat(header): added all header meta tags
ovflowd Jan 9, 2023
aa2dcf3
chore(document): added assets for theme switch
ovflowd Jan 9, 2023
c5e529c
chore(eslint): fixed eslint failed rule
ovflowd Jan 9, 2023
713d913
update nextra
shuding Jan 9, 2023
a805506
chore(document): added remaining scripts
ovflowd Jan 9, 2023
9da7a4f
feat(footer): added footer
ovflowd Jan 9, 2023
7218035
feat(header): updated header with favicon
ovflowd Jan 9, 2023
ac8c565
feat(manifest): added manifest for PWA
ovflowd Jan 9, 2023
74d5e07
feat(i18n): introduced i18n hook
ovflowd Jan 9, 2023
6880d0f
chore(header): added i18n config
ovflowd Jan 9, 2023
55a3732
feat(layouts): added default layout
ovflowd Jan 9, 2023
ad909f5
feat(layouts): initial version of the layout provider
ovflowd Jan 9, 2023
03e4c83
refactor(provider): cleaned-up the site provider
ovflowd Jan 9, 2023
dffe0af
feat(theme): adopted layout provider on theme
ovflowd Jan 9, 2023
68abfe5
chore(layouts): removed unused layouts
ovflowd Jan 9, 2023
1c957b8
feat(footer): added scroll-to-top
ovflowd Jan 9, 2023
729d257
chore(i18n): added navigation and translations
ovflowd Jan 10, 2023
b7c4d46
chore(dependencies): added highlightjs and classnames
ovflowd Jan 10, 2023
41b768b
chore(utils): added link locale util
ovflowd Jan 10, 2023
922fdbb
feat(i18n): introduced locale provider
ovflowd Jan 10, 2023
bc270b0
feat(header): renamed header into htmlhead
ovflowd Jan 10, 2023
61b6939
feat(header): introduced page header
ovflowd Jan 10, 2023
1db93b9
feat(components): introduced localised linkicomponent
ovflowd Jan 10, 2023
9ce8c72
feat(components): introduced language picker component
ovflowd Jan 10, 2023
80b8e9c
chore(footer): updated translation id
ovflowd Jan 10, 2023
a127bbc
feat(app): updated app, document and theme with new locale and scripts
ovflowd Jan 10, 2023
2d158d7
chore(layouts): added header to default layout
ovflowd Jan 10, 2023
1e14132
chore(layouts): removed old header layout
ovflowd Jan 10, 2023
5006fbb
chore(docs): made the docs index mdx compatible
ovflowd Jan 10, 2023
5aa43a0
chore(types): added labels to frontmatter
ovflowd Jan 10, 2023
cc40739
chore(config): updated next config and remark plugins
ovflowd Jan 10, 2023
b4e8f72
chore(types): added types for node-version-data
ovflowd Jan 10, 2023
b3954d2
feat(i18n): hook to support metadata about current route
ovflowd Jan 10, 2023
da37773
feat(navigation): updated navigation metadata
ovflowd Jan 10, 2023
843c600
feat(navigation): introduced a navigation hook
ovflowd Jan 10, 2023
0c57e96
feat(node-versions): introduced provider and types for node-versions
ovflowd Jan 10, 2023
c144490
feat(navigation): introduced side navigation component
ovflowd Jan 10, 2023
e693ec2
feat(header): use the new navigation component
ovflowd Jan 10, 2023
057cd9d
chore(app): introduced node data provider usage
ovflowd Jan 10, 2023
304c5e4
feat(docs): introduced doc layout
ovflowd Jan 10, 2023
6f559d4
chore(layouts): added docs to layout provider
ovflowd Jan 10, 2023
7e4c698
chore(layouts/scripts): removed now unused layouts and scripts
ovflowd Jan 10, 2023
4125fcc
chore(scripts): removed build scripts for node data
ovflowd Jan 10, 2023
59871bd
chore(utils): introduced new util
ovflowd Jan 10, 2023
5108087
chore(data): removed non-needed data anymore
ovflowd Jan 10, 2023
c8e8173
chore(navigation): include root entry on side nav
ovflowd Jan 10, 2023
3996fc5
fix(footer): fixed spacing of items
ovflowd Jan 10, 2023
63b9988
fix(body): next element to also follow body rules
ovflowd Jan 10, 2023
dbf9078
feat(layouts): introduced new layouts
ovflowd Jan 10, 2023
a38b159
chore(note): added todo notes on temporary components
ovflowd Jan 10, 2023
d2950c4
feat(mdx): added proper node api versions component
ovflowd Jan 10, 2023
188da41
chore(dependencies): removed non-needed dependencies
ovflowd Jan 10, 2023
3ebcaef
chore(docs): reverted mdx rename and use regular mdx provider for the…
ovflowd Jan 10, 2023
05fe823
chore(remark): a lot of the lists are unordered and shouldn't need to…
ovflowd Jan 10, 2023
40c82f0
chore(layouts): removed unused knowledge layouts
ovflowd Jan 10, 2023
669140c
feat(banner): introduced banner component
ovflowd Jan 10, 2023
cca892f
feat(nextra): allow plain md syntax; include i18n file in ssg
shuding Jan 11, 2023
270c55d
feat(next): introduced lambdas for getting data
ovflowd Jan 11, 2023
5357029
chore(eslint): added mjs to es6 context
ovflowd Jan 11, 2023
b378159
feat(next): adopted new data fetching mechanism
ovflowd Jan 11, 2023
173b534
feat(providers): updated providers with new data fetching
ovflowd Jan 11, 2023
347b400
chore(types): simplified provider types
ovflowd Jan 11, 2023
560ddbc
chore(i18n): added lts span
ovflowd Jan 11, 2023
37324c3
chore(next): improve next configuration
ovflowd Jan 11, 2023
1c316e4
feat(header): allow subpath match for sidenav
ovflowd Jan 11, 2023
a9d9729
chore(dependencies): added critters and sharp for css/image optimization
ovflowd Jan 11, 2023
05e146d
feat(caching): introduced caching of static async props
ovflowd Jan 11, 2023
c4364dc
fix(header): home location sublink
ovflowd Jan 11, 2023
70ac737
chore(hooks): removed .tsx extension
ovflowd Jan 11, 2023
53a4d1d
chore(scripts): removed unused scripts
ovflowd Jan 11, 2023
ec9f50e
feat(utils): added util for changelog link
ovflowd Jan 11, 2023
37b0585
feat(providers): provide nextra context
ovflowd Jan 11, 2023
9782bc2
chore(types): added numeric version
ovflowd Jan 11, 2023
dc84abb
feat(hooks): nextra context hook
ovflowd Jan 11, 2023
3819610
feat(components): download button component
ovflowd Jan 11, 2023
dcebdf9
feat(layouts): introduced index layout
ovflowd Jan 11, 2023
5fca766
feat(date): added format time util
ovflowd Jan 11, 2023
3939db6
chore(scripts): removed more unused scripts
ovflowd Jan 11, 2023
8c20bbd
disable flexsearch for now
shuding Jan 11, 2023
ef7ce9a
chore(next): increase memory pool for build
ovflowd Jan 12, 2023
c05a2d9
feat(data): updated hooks and how data is provided
ovflowd Jan 12, 2023
00c9bb7
chore(components): moved a few components around
ovflowd Jan 12, 2023
4644d41
chore(404): added dev 404 page
ovflowd Jan 12, 2023
e913c05
chore(i18n): added navigation and i18n for downloads
ovflowd Jan 12, 2023
9a9fd81
feat(download): introduced download components
ovflowd Jan 12, 2023
bcd73f3
feat(pages): introduced download pages
ovflowd Jan 12, 2023
e3fd213
feat(navigation): offer replacement of vars in link
ovflowd Jan 12, 2023
3b61c73
chore(scripts): updated a few scripts
ovflowd Jan 12, 2023
a352a64
chore(scripts): removed other deprecated script
ovflowd Jan 13, 2023
c38b647
chore(handlebars): added handlebars
ovflowd Jan 18, 2023
820a787
feat(release-post): contained release posts within the scripts folder
ovflowd Jan 18, 2023
fbf2212
chore(external): no need to have a package.json there anymore
ovflowd Jan 18, 2023
253a4a0
chore(release-post): minor typo fix
ovflowd Jan 18, 2023
3a6c2d5
chore(dependencies): added sw dependency
ovflowd Jan 18, 2023
9d50c76
chore(sw): enable sw feature
ovflowd Jan 18, 2023
bac2e22
chore(types): updated node data types
ovflowd Jan 18, 2023
2dd6b53
feat(components): introduced download table component
ovflowd Jan 18, 2023
98e8ce6
chore(layouts): introduced previous releases layout
ovflowd Jan 18, 2023
f9b8ba7
chore(scripts): added jquery as script
ovflowd Jan 18, 2023
8f2f901
refactor(components): use Link component
ovflowd Jan 18, 2023
81c247e
chore(downloads): use dompurify for the frontmatter modules
ovflowd Jan 18, 2023
9a40f2f
fix(links): fix api docs links
ovflowd Jan 18, 2023
a452393
fix(locale): fixed determination of route match
ovflowd Jan 18, 2023
57115f6
chore(deps): updated dependencies
ovflowd Jan 18, 2023
e015437
chore(helpers): introduced helper for getting a header link
ovflowd Jan 18, 2023
c6fdfc5
feat(heading): introduced anchored heading component
ovflowd Jan 18, 2023
fd6ddcd
chore(theme): adopted anchored component
ovflowd Jan 18, 2023
84ee4cc
chore(anchor): id is always provided
ovflowd Jan 18, 2023
80795e3
chore(dependencies): updated package json
ovflowd Jan 18, 2023
8564969
chore(mdx): transformed into mdx pages that need to be in mdx
ovflowd Jan 19, 2023
13638a9
chore(dependencies): updated dependencies
ovflowd Jan 19, 2023
0f20a34
chore(mdx): default config
ovflowd Jan 19, 2023
2722ec1
fix: upgrade nextra and refactor getNextData
shuding Jan 19, 2023
72ad9af
feat(layouts): introduced blog post layout
ovflowd Jan 19, 2023
ede7ae4
fix(release-post): end paragraph markings
ovflowd Jan 19, 2023
d9e7515
chore(layouts): sanitize to be memoized
ovflowd Jan 19, 2023
e7c2592
fix: only pass necessary node versions in page props
shuding Jan 19, 2023
6dd0480
chore(guides): removed non-translated guides
ovflowd Jan 19, 2023
054b653
fix(markdown): fix buffer guide markdown
ovflowd Jan 19, 2023
15568f1
feat(mdx): blockquote as highlightbox
ovflowd Jan 19, 2023
83641ce
fix(linting): fixed prettier rules for mdx
ovflowd Jan 19, 2023
39cf2cc
fix: /404 route and optimize page size
shuding Jan 19, 2023
ffda8c4
fix: optimize next build
shuding Jan 20, 2023
2c0b673
chore(canonical): add canonical
ovflowd Jan 20, 2023
6546723
refactor(data): simplified data gathering
ovflowd Jan 20, 2023
b45f40f
chore(dependencies): introducesd sitemap and swr
ovflowd Jan 20, 2023
ffebe0e
chore(ts): allow downlevel iteration
ovflowd Jan 20, 2023
9030c2e
fix(build): unoptimized images
ovflowd Jan 20, 2023
d3f69e4
feat(downloads): only latest major of each version
ovflowd Jan 20, 2023
b4466f5
chore(js): removed unused code
ovflowd Jan 20, 2023
7a2ef78
chore(404): prettified 404 file
ovflowd Jan 20, 2023
57eb58e
chore(footer): fixed # not valid
ovflowd Jan 20, 2023
d13a7b7
chore(i18n): add 404 page messages
ovflowd Jan 20, 2023
8a64af3
chore(404): use tsx instead of mdx
ovflowd Jan 20, 2023
d7d030e
chore(react-intl): no errors
ovflowd Jan 20, 2023
9502901
chore(i18n): fallback data
ovflowd Jan 20, 2023
f01219b
chore(ci): added build on ci again
ovflowd Jan 20, 2023
982179b
chore(sitemap): added sitemap data
ovflowd Jan 20, 2023
6695074
chore(eslint): prefer nodejs config
ovflowd Jan 20, 2023
b32162c
chore(fix): linting
ovflowd Jan 20, 2023
9dd0703
chore(scripts): remove server 404 and fix main.js for 404
ovflowd Jan 20, 2023
ca5bf9e
chore(build): is memory efficient now
ovflowd Jan 20, 2023
c3b3976
fix(i18n): always using english locale
ovflowd Jan 20, 2023
006082b
chore(next): updated config options
ovflowd Jan 20, 2023
9587276
feat(data): improved data rendering/reusability
ovflowd Jan 20, 2023
ce776a6
chore(next): remove non-necessary packages
ovflowd Jan 20, 2023
e8c407a
chore(scripts): refactored release-post to mjs
ovflowd Jan 20, 2023
972b8f6
chore(scripts): simplify and document code
ovflowd Jan 20, 2023
8e0c59d
chore(next): refactored data scripts
ovflowd Jan 20, 2023
826502a
refactor(header): i18n, svg and fix styles
ovflowd Jan 20, 2023
8c1f8f5
chore(next): minor refactor of helper
ovflowd Jan 20, 2023
a8e73d7
feat(node-data): only on selected routes
ovflowd Jan 20, 2023
1606340
fix(ts): fixed typescript types
ovflowd Jan 20, 2023
ae63ea8
refactor(providers): simplified the _app
ovflowd Jan 20, 2023
8661cc4
chore(dependencies): added gray-matter
ovflowd Jan 20, 2023
ad570ac
feat(helpers): introduced script helpers
ovflowd Jan 20, 2023
72c31a3
chore(types): updated types
ovflowd Jan 20, 2023
5d546ff
refactor(next): refactored data components
ovflowd Jan 20, 2023
efc6fd8
chore(sitemap): removed non-existent env
ovflowd Jan 20, 2023
77a22fa
chore(optimize): removed css optimization
ovflowd Jan 20, 2023
4210f36
feat(dat): introduced blog data helper
ovflowd Jan 20, 2023
5d2ff66
fix(blogdata): fixed slug
ovflowd Jan 20, 2023
8352e3c
feat(types): shared props and context
ovflowd Jan 20, 2023
c050765
feat(utils): added time component
ovflowd Jan 20, 2023
8fc5f0c
chore(gitignore): year pages
ovflowd Jan 20, 2023
69b4f7d
chore(types): refactored types
ovflowd Jan 20, 2023
634c112
chore(data): improved blog data and create year pages
ovflowd Jan 20, 2023
670195b
feat(blog): introduced blog index page
ovflowd Jan 20, 2023
7bc099f
feat(layouts): implemented blog category layout
ovflowd Jan 20, 2023
3328720
feat(i18n): migrate translations 🎉 (#1)
shanpriyan Jan 23, 2023
2002ec6
fix(document): numerours document style fixes and javascript fixes
ovflowd Jan 23, 2023
18b0e36
chore(eslint): global window
ovflowd Jan 23, 2023
597cd31
chore(external): moved external folders
ovflowd Jan 23, 2023
edb66e4
feat(rss): introduced rss generation
ovflowd Jan 23, 2023
b89f532
chore(tests): removed unused tests
ovflowd Jan 23, 2023
c6b7c29
chore(readme): updated readme
ovflowd Jan 23, 2023
6727512
chore(lint): ignore and fix linting
ovflowd Jan 23, 2023
cf3ae11
refactor(scripts): refactored the legacy scripts
ovflowd Jan 23, 2023
32ddc01
chore(ci): set memory to 4gb on ci
ovflowd Jan 23, 2023
d4fa511
chore(workers): no need tofr morkers
ovflowd Jan 23, 2023
3b29f2e
chore(ci): updated a doc and ci file
ovflowd Jan 23, 2023
09781bb
chore(refactor): minor refactors, text changes and bug fixes
ovflowd Jan 24, 2023
39eed0f
Update COLLABORATOR_GUIDE.md
ovflowd Jan 24, 2023
652952a
Apply suggestions from code review
ovflowd Jan 24, 2023
9e841e8
fix: upgrade nextra to remove the __esModule hack
shuding Jan 24, 2023
16b120f
chore: disable outputFileTracing
shuding Jan 24, 2023
a582517
chore(ci): use build cache
ovflowd Jan 24, 2023
987e49e
chore(js): fix theme switcher issues
ovflowd Jan 24, 2023
055e155
fix(build): improved data transmission from static props
ovflowd Jan 24, 2023
da9f8f7
chore(fixes): minor style and config changes
ovflowd Jan 24, 2023
dd3ccbc
fix(scrollto): minor scroll to fix
ovflowd Jan 24, 2023
0e9ce10
Update next.config.mjs
ovflowd Jan 24, 2023
b654432
chore(ci): attempt to optimize caching
ovflowd Jan 25, 2023
2200081
chore(ci): fine-tune to be based on eslint hashing
ovflowd Jan 25, 2023
db089e9
chore(cache): only cache .next/cache
ovflowd Jan 25, 2023
abf9ff0
chore(mastodon): added mastodon verification
ovflowd Feb 3, 2023
d6bcd66
chore(next): updated packages and optimised build performance
ovflowd Feb 25, 2023
54b6322
chore(dependencies): updated dependencies
ovflowd Mar 8, 2023
19dd5ac
fix(lint): fixed linting
ovflowd Mar 8, 2023
5e02b4b
chore(dependencies): removed temp dep
ovflowd Mar 8, 2023
735f7dd
chore(package): reduce memory
ovflowd Mar 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore(mdx): transformed into mdx pages that need to be in mdx
  • Loading branch information
ovflowd committed Mar 8, 2023
commit 8564969fe4f09efd225c54271f4e625ce0c5c997
2 changes: 1 addition & 1 deletion pages/ar/docs/index.md → pages/ar/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ labels:

يصف هذا التوثيق الوحدات المضمنة في الـ Node.js، وهو لا يوثق للوحدات المتوفرة عن طريق المجتمع.

<div class="highlight-box">
<div className="highlight-box">

### تبحث عن توثيق لنسخة سابقة؟

Expand Down
2 changes: 1 addition & 1 deletion pages/ca/docs/index.md → pages/ca/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ relacionats al mateix. També indica quins mètodes són a l'abast per les difer

També descriu els mòduls inclosos que proporciona Node.js, mes no documenta els mòduls que proporciona la comunitat.

<div class="highlight-box">
<div className="highlight-box">

### Buscant la referència de l'API per a una versió anterior?

Expand Down
2 changes: 1 addition & 1 deletion pages/de/docs/index.md → pages/de/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Methoden in den verschiedenen Node.js-Versionen verfügbar sind.
Die API-Referenz beschreibt Module, die in Node.js integriert sind. Module, die
von der Community zur Verfügung gestellt werden, sind dort nicht dokumentiert.

<div class="highlight-box">
<div className="highlight-box">

### Du suchst nach API Referenzen für ältere Versionen?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ interfering with my package's v2 copy. Everyone's code works!

## The Problem: Plugins

There's one use case where this falls down, however: *plugins*. A plugin package is meant to be used with another "host"
package, even though it does not always directly *use* the host package. There are many examples of this pattern in the
There's one use case where this falls down, however: _plugins_. A plugin package is meant to be used with another "host"
package, even though it does not always directly _use_ the host package. There are many examples of this pattern in the
Node.js package ecosystem already:

* Grunt [plugins](http://gruntjs.com/#plugins-all)
* Chai [plugins](http://chaijs.com/plugins)
* LevelUP [plugins](https://github.com/rvagg/node-levelup/wiki/Modules)
* Express [middleware](http://expressjs.com/api.html#middleware)
* Winston [transports](https://github.com/flatiron/winston/blob/master/docs/transports.md)
- Grunt [plugins](http://gruntjs.com/#plugins-all)
- Chai [plugins](http://chaijs.com/plugins)
- LevelUP [plugins](https://github.com/rvagg/node-levelup/wiki/Modules)
- Express [middleware](http://expressjs.com/api.html#middleware)
- Winston [transports](https://github.com/flatiron/winston/blob/master/docs/transports.md)

Even if you're not familiar with any of those use cases, surely you recall "jQuery plugins" from back when you were a
client-side developer: little `<script>`s you would drop into your page that would attach things to `jQuery.prototype`
for your later convenience.

In essence, plugins are designed to be used with host packages. But more importantly, they're designed to be used with
*particular versions* of host packages. For example, versions 1.x and 2.x of my `chai-as-promised` plugin work with
_particular versions_ of host packages. For example, versions 1.x and 2.x of my `chai-as-promised` plugin work with
`chai` version 0.5, whereas versions 3.x work with `chai` 1.x. Or, in the faster-paced and less-semver–friendly world of
Grunt plugins, version 0.3.1 of `grunt-contrib-stylus` works with `grunt` 0.4.0rc4, but breaks when used with `grunt`
0.4.0rc5 due to removed APIs.
Expand Down Expand Up @@ -81,7 +81,7 @@ your imagination.

What we need is a way of expressing these "dependencies" between plugins and their host package. Some way of saying, "I
only work when plugged in to version 1.2.x of my host package, so if you install me, be sure that it's alongside a
compatible host." We call this relationship a *peer dependency*.
compatible host." We call this relationship a _peer dependency_.

The peer dependency idea has been kicked around for [literally](https://github.com/isaacs/npm/issues/930)
[years](https://github.com/isaacs/npm/issues/1400). After
Expand Down Expand Up @@ -122,11 +122,14 @@ peer-depend on, and add it to your `package.json`:
Now, when installing `chai-as-promised`, the `chai` package will come along with it. And if later you try to install
another Chai plugin that only works with 0.x versions of Chai, you'll get an error. Nice!

<div class="highlight-box">
<strong>UPDATE:</strong> npm versions 1, 2, and 7 will automatically install peerDependencies if they are not explicitly depended upon higher in the dependency tree. For npm versions 3 through 6, you will receive a warning that the peerDependency is not installed instead.
<div className="highlight-box">
<strong>UPDATE:</strong> npm versions 1, 2, and 7 will automatically install
peerDependencies if they are not explicitly depended upon higher in the
dependency tree. For npm versions 3 through 6, you will receive a warning that
the peerDependency is not installed instead.
</div>

One piece of advice: peer dependency requirements, unlike those for regular dependencies, *should be lenient*. You
One piece of advice: peer dependency requirements, unlike those for regular dependencies, _should be lenient_. You
should not lock your peer dependencies down to specific patch versions. It would be really annoying if one Chai plugin
peer-depended on Chai 1.4.1, while another depended on Chai 1.5.0, simply because the authors were lazy and didn't spend
the time figuring out the actual minimum version of Chai they are compatible with.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ layout: docs.hbs

This guide explains how to migrate to safe `Buffer` constructor methods. The migration fixes the following deprecation warning:

<div class="highlight-box">
The Buffer() and new Buffer() constructors are not recommended for use due to security and usability concerns. Please use the new Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() construction methods instead.
<div className="highlight-box">
The Buffer() and new Buffer() constructors are not recommended for use due to
security and usability concerns. Please use the new Buffer.alloc(),
Buffer.allocUnsafe(), or Buffer.from() construction methods instead.
</div>

* [Variant 1: Drop support for Node.js ≤ 4.4.x and 5.0.0 — 5.9.x](#variant-1) (*recommended*)
* [Variant 2: Use a polyfill](#variant-2)
* [Variant 3: Manual detection, with safeguards](#variant-3)
- [Variant 1: Drop support for Node.js ≤ 4.4.x and 5.0.0 — 5.9.x](#variant-1) (_recommended_)
- [Variant 2: Use a polyfill](#variant-2)
- [Variant 3: Manual detection, with safeguards](#variant-3)

### Finding problematic bits of code using `grep`

Expand All @@ -28,9 +30,9 @@ exceptions).

If you’re using Node.js ≥ 8.0.0 (which is recommended), Node.js exposes multiple options that help with finding the relevant pieces of code:

* `--trace-warnings` will make Node.js show a stack trace for this warning and other warnings that are printed by Node.js.
* `--trace-deprecation` does the same thing, but only for deprecation warnings.
* `--pending-deprecation` will show more types of deprecation warnings. In particular, it will show the `Buffer()` deprecation warning, even on Node.js 8.
- `--trace-warnings` will make Node.js show a stack trace for this warning and other warnings that are printed by Node.js.
- `--trace-deprecation` does the same thing, but only for deprecation warnings.
- `--pending-deprecation` will show more types of deprecation warnings. In particular, it will show the `Buffer()` deprecation warning, even on Node.js 8.

You can set these flags using environment variables:

Expand Down Expand Up @@ -63,13 +65,13 @@ described above.

This is the recommended solution nowadays that would imply only minimal overhead.

The Node.js 5.x release line has been unsupported since July 2016, and the Node.js 4.x release line reaches its End of Life in April 2018 (→ [Schedule](https://github.com/nodejs/Release#release-schedule)). This means that these versions of Node.js will *not* receive any updates, even in case of security issues, so using these release lines should be avoided, if at all possible.
The Node.js 5.x release line has been unsupported since July 2016, and the Node.js 4.x release line reaches its End of Life in April 2018 (→ [Schedule](https://github.com/nodejs/Release#release-schedule)). This means that these versions of Node.js will _not_ receive any updates, even in case of security issues, so using these release lines should be avoided, if at all possible.

What you would do in this case is to convert all `new Buffer()` or `Buffer()` calls to use `Buffer.alloc()` or `Buffer.from()`, in the following way:

* For `new Buffer(number)`, replace it with `Buffer.alloc(number)`.
* For `new Buffer(string)` (or `new Buffer(string, encoding)`), replace it with `Buffer.from(string)` (or `Buffer.from(string, encoding)`).
* For all other combinations of arguments (these are much rarer), also replace `new Buffer(...arguments)` with `Buffer.from(...arguments)`.
- For `new Buffer(number)`, replace it with `Buffer.alloc(number)`.
- For `new Buffer(string)` (or `new Buffer(string, encoding)`), replace it with `Buffer.from(string)` (or `Buffer.from(string, encoding)`).
- For all other combinations of arguments (these are much rarer), also replace `new Buffer(...arguments)` with `Buffer.from(...arguments)`.

Note that `Buffer.alloc()` is also _faster_ on the current Node.js versions than
`new Buffer(size).fill(0)`, which is what you would otherwise need to ensure zero-filling.
Expand All @@ -93,7 +95,7 @@ your users will not observe a runtime deprecation warning when running your code

There are three different polyfills available:

* **[safer-buffer](https://www.npmjs.com/package/safer-buffer)** is a drop-in replacement for the
- **[safer-buffer](https://www.npmjs.com/package/safer-buffer)** is a drop-in replacement for the
entire `Buffer` API, that will _throw_ when using `new Buffer()`.

You would take exactly the same steps as in [Variant 1](#variant-1), but with a polyfill
Expand All @@ -102,7 +104,7 @@ There are three different polyfills available:
Do not use the old `new Buffer()` API. In any files where the line above is added,
using old `new Buffer()` API will _throw_.

* **[buffer-from](https://www.npmjs.com/package/buffer-from) and/or
- **[buffer-from](https://www.npmjs.com/package/buffer-from) and/or
[buffer-alloc](https://www.npmjs.com/package/buffer-alloc)** are
[ponyfills](https://ponyfill.com/) for their respective part of the `Buffer` API. You only need
to add the package(s) corresponding to the API you are using.
Expand All @@ -114,7 +116,7 @@ There are three different polyfills available:
A downside with this approach is slightly more code changes to migrate off them (as you would be
using e.g. `Buffer.from()` under a different name).

* **[safe-buffer](https://www.npmjs.com/package/safe-buffer)** is also a drop-in replacement for
- **[safe-buffer](https://www.npmjs.com/package/safe-buffer)** is also a drop-in replacement for
the entire `Buffer` API, but using `new Buffer()` will still work as before.

A downside to this approach is that it will allow you to also use the older `new Buffer()` API
Expand Down Expand Up @@ -205,13 +207,13 @@ const buf = Buffer.alloc ? Buffer.alloc(number) : new Buffer(number).fill(0);

Be extra cautious when using `Buffer.allocUnsafe()`:

* Don't use it if you don't have a good reason to
* e.g. you probably won't ever see a performance difference for small buffers, in fact, those
- Don't use it if you don't have a good reason to
- e.g. you probably won't ever see a performance difference for small buffers, in fact, those
might be even faster with `Buffer.alloc()`,
* if your code is not in the hot code path — you also probably won't notice a difference,
* keep in mind that zero-filling minimizes the potential risks.
* If you use it, make sure that you never return the buffer in a partially-filled state,
* if you are writing to it sequentially — always truncate it to the actual written length
- if your code is not in the hot code path — you also probably won't notice a difference,
- keep in mind that zero-filling minimizes the potential risks.
- If you use it, make sure that you never return the buffer in a partially-filled state,
- if you are writing to it sequentially — always truncate it to the actual written length

Errors in handling buffers allocated with `Buffer.allocUnsafe()` could result in various issues,
ranged from undefined behavior of your code to sensitive data (user input, passwords, certs)
Expand All @@ -226,17 +228,17 @@ version (and lacking type checks also adds DoS to the list of potential problems

The `Buffer` constructor could be used to create a buffer in many different ways:

* `new Buffer(42)` creates a `Buffer` of 42 bytes. Before Node.js 8, this buffer contained
*arbitrary memory* for performance reasons, which could include anything ranging from
- `new Buffer(42)` creates a `Buffer` of 42 bytes. Before Node.js 8, this buffer contained
_arbitrary memory_ for performance reasons, which could include anything ranging from
program source code to passwords and encryption keys.
* `new Buffer('abc')` creates a `Buffer` that contains the UTF-8-encoded version of
- `new Buffer('abc')` creates a `Buffer` that contains the UTF-8-encoded version of
the string `'abc'`. A second argument could specify another encoding: for example,
`new Buffer(string, 'base64')` could be used to convert a Base64 string into the original
sequence of bytes that it represents.
* There are several other combinations of arguments.
- There are several other combinations of arguments.

This meant that in code like `var buffer = new Buffer(foo);`, *it is not possible to tell
what exactly the contents of the generated buffer are* without knowing the type of `foo`.
This meant that in code like `var buffer = new Buffer(foo);`, _it is not possible to tell
what exactly the contents of the generated buffer are_ without knowing the type of `foo`.

Sometimes, the value of `foo` comes from an external source. For example, this function
could be exposed as a service on a web server, converting a UTF-8 string into its Base64 form:
Expand All @@ -250,20 +252,20 @@ function stringToBase64(req, res) {
}
```

Note that this code does *not* validate the type of `req.body.string`:
Note that this code does _not_ validate the type of `req.body.string`:

* `req.body.string` is expected to be a string. If this is the case, all goes well.
* `req.body.string` is controlled by the client that sends the request.
* If `req.body.string` is the *number* `50`, the `rawBytes` would be `50` bytes:
* Before Node.js 8, the content would be uninitialized
* After Node.js 8, the content would be `50` bytes with the value `0`
- `req.body.string` is expected to be a string. If this is the case, all goes well.
- `req.body.string` is controlled by the client that sends the request.
- If `req.body.string` is the _number_ `50`, the `rawBytes` would be `50` bytes:
- Before Node.js 8, the content would be uninitialized
- After Node.js 8, the content would be `50` bytes with the value `0`

Because of the missing type check, an attacker could intentionally send a number
as part of the request. Using this, they can either:

* Read uninitialized memory. This **will** leak passwords, encryption keys and other
- Read uninitialized memory. This **will** leak passwords, encryption keys and other
kinds of sensitive information. (Information leak)
* Force the program to allocate a large amount of memory. For example, when specifying
- Force the program to allocate a large amount of memory. For example, when specifying
`500000000` as the input value, each request will allocate 500MB of memory.
This can be used to either exhaust the memory available of a program completely
and make it crash, or slow it down significantly. (Denial of Service)
Expand All @@ -279,4 +281,4 @@ handled by the program.

Surveys of code in the `npm` ecosystem have shown that the `Buffer()` constructor is still
widely used. This includes new code, and overall usage of such code has actually been
*increasing*.
_increasing_.
2 changes: 1 addition & 1 deletion pages/en/docs/index.md → pages/en/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The [API reference documentation](https://nodejs.org/api/) provides detailed inf

This documentation describes the built-in modules provided by Node.js. It does not document modules provided by the community.

<div class="highlight-box">
<div className="highlight-box">

### Looking for API docs of previous releases?

Expand Down
Loading