Skip to content

Commit

Permalink
Merge branch 'main' into perf-testing-2
Browse files Browse the repository at this point in the history
  • Loading branch information
billouboq authored Aug 23, 2023
2 parents a80e4e2 + 0664840 commit d6d8979
Show file tree
Hide file tree
Showing 11 changed files with 586 additions and 514 deletions.
5 changes: 4 additions & 1 deletion .github/scripts/highlights.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ async function pullRequestHighlights(prs) {
if (!highlights.length) return '';

highlights.unshift('## Release Notes\n\n');
return highlights.join('\n\n');

const highlight = highlights.join('\n\n');
console.log(`Total highlight is ${highlight.length} characters long`);
return highlight;
}

console.log('List of PRs to collect highlights from:', prs);
Expand Down
12 changes: 8 additions & 4 deletions .github/scripts/pr_list.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ const historyFilePath = path.join(__dirname, '..', '..', 'HISTORY.md');
*/
function parsePRList(history) {
const prRegexp = /js-bson\/issues\/(?<prNum>\d+)\)/iu;
return history
.split('\n')
.map(line => prRegexp.exec(line)?.groups?.prNum ?? '')
.filter(prNum => prNum !== '');
return Array.from(
new Set(
history
.split('\n')
.map(line => prRegexp.exec(line)?.groups?.prNum ?? '')
.filter(prNum => prNum !== '')
)
);
}

const historyContents = await fs.readFile(historyFilePath, { encoding: 'utf8' });
Expand Down
24 changes: 24 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [6.0.0-alpha.0](https://github.com/mongodb/js-bson/compare/v5.4.0...v6.0.0-alpha.0) (2023-08-15)


### ⚠ BREAKING CHANGES

* **NODE-5504:** bump bson major version (#605)
* **NODE-4770:** remove 12 length string support from ObjectId constructor (#601)
* **NODE-4769:** remove ISO-8859-1 string support from Binary (#602)
* **NODE-5223:** remove deprecated cacheHexString (#595)
* **NODE-4787:** bump minimum Node.js version to v16.20.1 (#590)

### Features

* **NODE-4769:** remove ISO-8859-1 string support from Binary ([#602](https://github.com/mongodb/js-bson/issues/602)) ([74f7f8a](https://github.com/mongodb/js-bson/commit/74f7f8a447fa0b0b1557cba14e75ff052df54d13))
* **NODE-4770:** remove 12 length string support from ObjectId constructor ([#601](https://github.com/mongodb/js-bson/issues/601)) ([409c592](https://github.com/mongodb/js-bson/commit/409c592524a6eec6a89eb96dee4b51e4f8adf5ae))
* **NODE-4787:** bump minimum Node.js version to v16.20.1 ([#590](https://github.com/mongodb/js-bson/issues/590)) ([1dcca92](https://github.com/mongodb/js-bson/commit/1dcca92b24e609a069ca7f4187e5b9521380b2f5))
* **NODE-5223:** remove deprecated cacheHexString ([#595](https://github.com/mongodb/js-bson/issues/595)) ([76eca2b](https://github.com/mongodb/js-bson/commit/76eca2b44c5fd0a4f4d5037346a29c2f9a5350b5))
* **NODE-5504:** bump bson major version ([#605](https://github.com/mongodb/js-bson/issues/605)) ([9615902](https://github.com/mongodb/js-bson/commit/9615902943927646562c145604fc477cd42e9ce6))


### Bug Fixes

* **NODE-5509:** Allow undefined or null params in ObjectId.equals ([#607](https://github.com/mongodb/js-bson/issues/607)) ([e2674c6](https://github.com/mongodb/js-bson/commit/e2674c6c2940d81e5de5b6c9500391ce5b1a2649))

## [5.4.0](https://github.com/mongodb/js-bson/compare/v5.3.0...v5.4.0) (2023-07-03)


Expand Down
79 changes: 47 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ BSON is short for "Binary JSON," and is the binary-encoded serialization of JSON
You can learn more about it in [the specification](http://bsonspec.org).

### Table of Contents

- [Usage](#usage)
- [Bugs/Feature Requests](#bugs--feature-requests)
- [Installation](#installation)
Expand All @@ -18,7 +19,7 @@ Think you've found a bug? Want to see a new feature in `bson`? Please open a cas
2. Navigate to the NODE project: [jira.mongodb.org/browse/NODE](https://jira.mongodb.org/browse/NODE)
3. Click **Create Issue** - Please provide as much information as possible about the issue and how to reproduce it.

Bug reports in JIRA for all driver projects (i.e. NODE, PYTHON, CSHARP, JAVA) and the Core Server (i.e. SERVER) project are **public**.
Bug reports in JIRA for the NODE driver project are **public**.

## Usage

Expand Down Expand Up @@ -67,41 +68,52 @@ If you are working directly in the browser without a bundler please use the `.mj
npm install bson
```

### MongoDB Node.js Driver Version Compatibility

Only the following version combinations with the [MongoDB Node.js Driver](https://github.com/mongodb/node-mongodb-native) are considered stable.

| | `[email protected]` | `[email protected]` | `[email protected]` | `[email protected]` |
| ------------- | ---------- | ---------- | ---------- | ---------- |
| `[email protected]` | N/A | N/A | N/A ||
| `[email protected]` | N/A | N/A || N/A |
| `[email protected]` | N/A || N/A | N/A |
| `[email protected]` || N/A | N/A | N/A |

## Documentation

### BSON
### BSON

[API documentation](https://mongodb.github.io/node-mongodb-native/Next/modules/BSON.html)

<a name="EJSON"></a>

### EJSON

* [EJSON](#EJSON)

* [.parse(text, [options])](#EJSON.parse)
- [EJSON](#EJSON)

* [.stringify(value, [replacer], [space], [options])](#EJSON.stringify)
- [.parse(text, [options])](#EJSON.parse)

* [.serialize(bson, [options])](#EJSON.serialize)
- [.stringify(value, [replacer], [space], [options])](#EJSON.stringify)

* [.deserialize(ejson, [options])](#EJSON.deserialize)
- [.serialize(bson, [options])](#EJSON.serialize)

- [.deserialize(ejson, [options])](#EJSON.deserialize)

<a name="EJSON.parse"></a>

#### *EJSON*.parse(text, [options])
#### _EJSON_.parse(text, [options])

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| text | <code>string</code> | | |
| [options] | <code>object</code> | | Optional settings |
| Param | Type | Default | Description |
| ----------------- | -------------------- | ----------------- | ---------------------------------------------------------------------------------- |
| text | <code>string</code> | | |
| [options] | <code>object</code> | | Optional settings |
| [options.relaxed] | <code>boolean</code> | <code>true</code> | Attempt to return native JS types where possible, rather than BSON types (if true) |

Parse an Extended JSON string, constructing the JavaScript value or object described by that
string.

**Example**

```js
const { EJSON } = require('bson');
const text = '{ "int32": { "$numberInt": "10" } }';
Expand All @@ -112,24 +124,26 @@ console.log(EJSON.parse(text, { relaxed: false }));
// prints { int32: 10 }
console.log(EJSON.parse(text));
```

<a name="EJSON.stringify"></a>

#### *EJSON*.stringify(value, [replacer], [space], [options])
#### _EJSON_.stringify(value, [replacer], [space], [options])

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| value | <code>object</code> | | The value to convert to extended JSON |
| [replacer] | <code>function</code> \| <code>array</code> | | A function that alters the behavior of the stringification process, or an array of String and Number objects that serve as a whitelist for selecting/filtering the properties of the value object to be included in the JSON string. If this value is null or not provided, all properties of the object are included in the resulting JSON string |
| [space] | <code>string</code> \| <code>number</code> | | A String or Number object that's used to insert white space into the output JSON string for readability purposes. |
| [options] | <code>object</code> | | Optional settings |
| [options.relaxed] | <code>boolean</code> | <code>true</code> | Enabled Extended JSON's `relaxed` mode |
| [options.legacy] | <code>boolean</code> | <code>true</code> | Output in Extended JSON v1 |
| Param | Type | Default | Description |
| ----------------- | ------------------------------------------- | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| value | <code>object</code> | | The value to convert to extended JSON |
| [replacer] | <code>function</code> \| <code>array</code> | | A function that alters the behavior of the stringification process, or an array of String and Number objects that serve as a whitelist for selecting/filtering the properties of the value object to be included in the JSON string. If this value is null or not provided, all properties of the object are included in the resulting JSON string |
| [space] | <code>string</code> \| <code>number</code> | | A String or Number object that's used to insert white space into the output JSON string for readability purposes. |
| [options] | <code>object</code> | | Optional settings |
| [options.relaxed] | <code>boolean</code> | <code>true</code> | Enabled Extended JSON's `relaxed` mode |
| [options.legacy] | <code>boolean</code> | <code>true</code> | Output in Extended JSON v1 |

Converts a BSON document to an Extended JSON string, optionally replacing values if a replacer
function is specified or optionally including only the specified properties if a replacer array
is specified.

**Example**

```js
const { EJSON } = require('bson');
const Int32 = require('mongodb').Int32;
Expand All @@ -141,24 +155,25 @@ console.log(EJSON.stringify(doc, { relaxed: false }));
// prints '{"int32":10}'
console.log(EJSON.stringify(doc));
```

<a name="EJSON.serialize"></a>

#### *EJSON*.serialize(bson, [options])
#### _EJSON_.serialize(bson, [options])

| Param | Type | Description |
| --- | --- | --- |
| bson | <code>object</code> | The object to serialize |
| Param | Type | Description |
| --------- | ------------------- | ---------------------------------------------------- |
| bson | <code>object</code> | The object to serialize |
| [options] | <code>object</code> | Optional settings passed to the `stringify` function |

Serializes an object to an Extended JSON string, and reparse it as a JavaScript object.

<a name="EJSON.deserialize"></a>

#### *EJSON*.deserialize(ejson, [options])
#### _EJSON_.deserialize(ejson, [options])

| Param | Type | Description |
| --- | --- | --- |
| ejson | <code>object</code> | The Extended JSON object to deserialize |
| Param | Type | Description |
| --------- | ------------------- | -------------------------------------------- |
| ejson | <code>object</code> | The Extended JSON object to deserialize |
| [options] | <code>object</code> | Optional settings passed to the parse method |

Deserializes an Extended JSON object into a plain JavaScript object with native/BSON types
Expand Down Expand Up @@ -194,7 +209,7 @@ BSON vendors the required polyfills for `TextEncoder`, `TextDecoder`, `atob`, `b
npm install --save react-native-get-random-values
```

The following snippet should be placed at the top of the entrypoint (by default this is the root `index.js` file) for React Native projects using the BSON library. These lines must be placed for any code that imports `BSON`.
The following snippet should be placed at the top of the entrypoint (by default this is the root `index.js` file) for React Native projects using the BSON library. These lines must be placed for any code that imports `BSON`.

```typescript
// Required Polyfills For ReactNative
Expand All @@ -211,7 +226,7 @@ This will cause React Native to import the `node_modules/bson/lib/bson.rn.cjs` b

### Technical Note about React Native module import

The `"exports"` definition in our `package.json` will result in BSON's CommonJS bundle being imported in a React Native project instead of the ES module bundle. Importing the CommonJS bundle is necessary because BSON's ES module bundle of BSON uses top-level await, which is not supported syntax in [React Native's runtime hermes](https://hermesengine.dev/).
The `"exports"` definition in our `package.json` will result in BSON's CommonJS bundle being imported in a React Native project instead of the ES module bundle. Importing the CommonJS bundle is necessary because BSON's ES module bundle of BSON uses top-level await, which is not supported syntax in [React Native's runtime hermes](https://hermesengine.dev/).

## FAQ

Expand Down
2 changes: 1 addition & 1 deletion etc/eslint/no-bigint-usage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"devDependencies": {
"chai": "^4.3.7",
"eslint": "^8.33.0",
"eslint": "^8.46.0",
"mocha": "^10.2.0"
}
}
Loading

0 comments on commit d6d8979

Please sign in to comment.