![]() API-first authentication, authorization, and fraud prevention + | We’re bound by one common purpose: to give you the financial tools, resources and information you ne... + | ![]() Hi, we're Descope! We are building something in the authentication space for app developers and... + |
![]() At Buzzoid, you can buy Instagram followers quickly, safely, and easily with just a few clicks. Rate... + | ![]() At Famety, you can grow your social media following quickly, safely, and easily with just a few clic... + | ![]() Buy Instagram Likes + |
💜 Become a sponsor + | 💜 Become a sponsor + | 💜 Become a sponsor + |
Promise based HTTP client for the browser and node.js
+ ++ Website • + Documentation +
+ +string
| | |
+| [options] | object
| | Optional settings |
+| [options.relaxed] | boolean
| true
| 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" } }';
+
+// prints { int32: { [String: '10'] _bsontype: 'Int32', value: '10' } }
+console.log(EJSON.parse(text, { relaxed: false }));
+
+// prints { int32: 10 }
+console.log(EJSON.parse(text));
+```
+
+
+
+#### _EJSON_.stringify(value, [replacer], [space], [options])
+
+| Param | Type | Default | Description |
+| ----------------- | ------------------------------------------- | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| value | object
| | The value to convert to extended JSON |
+| [replacer] | function
\| array
| | 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] | string
\| number
| | A String or Number object that's used to insert white space into the output JSON string for readability purposes. |
+| [options] | object
| | Optional settings |
+| [options.relaxed] | boolean
| true
| Enabled Extended JSON's `relaxed` mode |
+| [options.legacy] | boolean
| true
| 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;
+const doc = { int32: new Int32(10) };
+
+// prints '{"int32":{"$numberInt":"10"}}'
+console.log(EJSON.stringify(doc, { relaxed: false }));
+
+// prints '{"int32":10}'
+console.log(EJSON.stringify(doc));
+```
+
+
+
+#### _EJSON_.serialize(bson, [options])
+
+| Param | Type | Description |
+| --------- | ------------------- | ---------------------------------------------------- |
+| bson | object
| The object to serialize |
+| [options] | object
| Optional settings passed to the `stringify` function |
+
+Serializes an object to an Extended JSON string, and reparse it as a JavaScript object.
+
+
+
+#### _EJSON_.deserialize(ejson, [options])
+
+| Param | Type | Description |
+| --------- | ------------------- | -------------------------------------------- |
+| ejson | object
| The Extended JSON object to deserialize |
+| [options] | object
| Optional settings passed to the parse method |
+
+Deserializes an Extended JSON object into a plain JavaScript object with native/BSON types
+
+## Error Handling
+
+It is our recommendation to use `BSONError.isBSONError()` checks on errors and to avoid relying on parsing `error.message` and `error.name` strings in your code. We guarantee `BSONError.isBSONError()` checks will pass according to semver guidelines, but errors may be sub-classed or their messages may change at any time, even patch releases, as we see fit to increase the helpfulness of the errors.
+
+Any new errors we add to the driver will directly extend an existing error class and no existing error will be moved to a different parent class outside of a major release.
+This means `BSONError.isBSONError()` will always be able to accurately capture the errors that our BSON library throws.
+
+Hypothetical example: A collection in our Db has an issue with UTF-8 data:
+
+```ts
+let documentCount = 0;
+const cursor = collection.find({}, { utf8Validation: true });
+try {
+ for await (const doc of cursor) documentCount += 1;
+} catch (error) {
+ if (BSONError.isBSONError(error)) {
+ console.log(`Found the troublemaker UTF-8!: ${documentCount} ${error.message}`);
+ return documentCount;
+ }
+ throw error;
+}
+```
+
+## React Native
+
+BSON vendors the required polyfills for `TextEncoder`, `TextDecoder`, `atob`, `btoa` imported from React Native and therefore doesn't expect users to polyfill these. One additional polyfill, `crypto.getRandomValues` is recommended and can be installed with the following command:
+
+```sh
+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`.
+
+```typescript
+// Required Polyfills For ReactNative
+import 'react-native-get-random-values';
+```
+
+Finally, import the `BSON` library like so:
+
+```typescript
+import { BSON, EJSON } from 'bson';
+```
+
+This will cause React Native to import the `node_modules/bson/lib/bson.rn.cjs` bundle (see the `"react-native"` setting we have in the `"exports"` section of our [package.json](./package.json).)
+
+### 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/).
+
+## FAQ
+
+#### Why does `undefined` get converted to `null`?
+
+The `undefined` BSON type has been [deprecated for many years](http://bsonspec.org/spec.html), so this library has dropped support for it. Use the `ignoreUndefined` option (for example, from the [driver](http://mongodb.github.io/node-mongodb-native/2.2/api/MongoClient.html#connect) ) to instead remove `undefined` keys.
+
+#### How do I add custom serialization logic?
+
+This library looks for `toBSON()` functions on every path, and calls the `toBSON()` function to get the value to serialize.
+
+```javascript
+const BSON = require('bson');
+
+class CustomSerialize {
+ toBSON() {
+ return 42;
+ }
+}
+
+const obj = { answer: new CustomSerialize() };
+// "{ answer: 42 }"
+console.log(BSON.deserialize(BSON.serialize(obj)));
+```
diff --git a/hackathon/DIKSHA-Novathon/node_modules/bson/bson.d.ts b/hackathon/DIKSHA-Novathon/node_modules/bson/bson.d.ts
new file mode 100644
index 00000000..14e57096
--- /dev/null
+++ b/hackathon/DIKSHA-Novathon/node_modules/bson/bson.d.ts
@@ -0,0 +1,1723 @@
+/**
+ * A class representation of the BSON Binary type.
+ * @public
+ * @category BSONType
+ */
+export declare class Binary extends BSONValue {
+ get _bsontype(): 'Binary';
+ /* Excluded from this release type: BSON_BINARY_SUBTYPE_DEFAULT */
+ /** Initial buffer default size */
+ static readonly BUFFER_SIZE = 256;
+ /** Default BSON type */
+ static readonly SUBTYPE_DEFAULT = 0;
+ /** Function BSON type */
+ static readonly SUBTYPE_FUNCTION = 1;
+ /** Byte Array BSON type */
+ static readonly SUBTYPE_BYTE_ARRAY = 2;
+ /** Deprecated UUID BSON type @deprecated Please use SUBTYPE_UUID */
+ static readonly SUBTYPE_UUID_OLD = 3;
+ /** UUID BSON type */
+ static readonly SUBTYPE_UUID = 4;
+ /** MD5 BSON type */
+ static readonly SUBTYPE_MD5 = 5;
+ /** Encrypted BSON type */
+ static readonly SUBTYPE_ENCRYPTED = 6;
+ /** Column BSON type */
+ static readonly SUBTYPE_COLUMN = 7;
+ /** Sensitive BSON type */
+ static readonly SUBTYPE_SENSITIVE = 8;
+ /** Vector BSON type */
+ static readonly SUBTYPE_VECTOR = 9;
+ /** User BSON type */
+ static readonly SUBTYPE_USER_DEFINED = 128;
+ /** datatype of a Binary Vector (subtype: 9) */
+ static readonly VECTOR_TYPE: Readonly<{
+ readonly Int8: 3;
+ readonly Float32: 39;
+ readonly PackedBit: 16;
+ }>;
+ /**
+ * The bytes of the Binary value.
+ *
+ * The format of a Binary value in BSON is defined as:
+ * ```txt
+ * binary ::= int32 subtype (byte*)
+ * ```
+ *
+ * This `buffer` is the "(byte*)" segment.
+ *
+ * Unless the value is subtype 2, then deserialize will read the first 4 bytes as an int32 and set this to the remaining bytes.
+ *
+ * ```txt
+ * binary ::= int32 unsigned_byte(2) int32 (byte*)
+ * ```
+ *
+ * @see https://bsonspec.org/spec.html
+ */
+ buffer: Uint8Array;
+ /**
+ * The binary subtype.
+ *
+ * Current defined values are:
+ *
+ * - `unsigned_byte(0)` Generic binary subtype
+ * - `unsigned_byte(1)` Function
+ * - `unsigned_byte(2)` Binary (Deprecated)
+ * - `unsigned_byte(3)` UUID (Deprecated)
+ * - `unsigned_byte(4)` UUID
+ * - `unsigned_byte(5)` MD5
+ * - `unsigned_byte(6)` Encrypted BSON value
+ * - `unsigned_byte(7)` Compressed BSON column
+ * - `unsigned_byte(8)` Sensitive
+ * - `unsigned_byte(9)` Vector
+ * - `unsigned_byte(128)` - `unsigned_byte(255)` User defined
+ */
+ sub_type: number;
+ /**
+ * The Binary's `buffer` can be larger than the Binary's content.
+ * This property is used to determine where the content ends in the buffer.
+ */
+ position: number;
+ /**
+ * Create a new Binary instance.
+ * @param buffer - a buffer object containing the binary data.
+ * @param subType - the option binary type.
+ */
+ constructor(buffer?: BinarySequence, subType?: number);
+ /**
+ * Updates this binary with byte_value.
+ *
+ * @param byteValue - a single byte we wish to write.
+ */
+ put(byteValue: string | number | Uint8Array | number[]): void;
+ /**
+ * Writes a buffer to the binary.
+ *
+ * @param sequence - a string or buffer to be written to the Binary BSON object.
+ * @param offset - specify the binary of where to write the content.
+ */
+ write(sequence: BinarySequence, offset: number): void;
+ /**
+ * Returns a view of **length** bytes starting at **position**.
+ *
+ * @param position - read from the given position in the Binary.
+ * @param length - the number of bytes to read.
+ */
+ read(position: number, length: number): Uint8Array;
+ /** returns a view of the binary value as a Uint8Array */
+ value(): Uint8Array;
+ /** the length of the binary sequence */
+ length(): number;
+ toJSON(): string;
+ toString(encoding?: 'hex' | 'base64' | 'utf8' | 'utf-8'): string;
+ /* Excluded from this release type: toExtendedJSON */
+ toUUID(): UUID;
+ /** Creates an Binary instance from a hex digit string */
+ static createFromHexString(hex: string, subType?: number): Binary;
+ /** Creates an Binary instance from a base64 string */
+ static createFromBase64(base64: string, subType?: number): Binary;
+ /* Excluded from this release type: fromExtendedJSON */
+ inspect(depth?: number, options?: unknown, inspect?: InspectFn): string;
+ /**
+ * If this Binary represents a Int8 Vector (`binary.buffer[0] === Binary.VECTOR_TYPE.Int8`),
+ * returns a copy of the bytes in a new Int8Array.
+ *
+ * If the Binary is not a Vector, or the datatype is not Int8, an error is thrown.
+ */
+ toInt8Array(): Int8Array;
+ /**
+ * If this Binary represents a Float32 Vector (`binary.buffer[0] === Binary.VECTOR_TYPE.Float32`),
+ * returns a copy of the bytes in a new Float32Array.
+ *
+ * If the Binary is not a Vector, or the datatype is not Float32, an error is thrown.
+ */
+ toFloat32Array(): Float32Array;
+ /**
+ * If this Binary represents packed bit Vector (`binary.buffer[0] === Binary.VECTOR_TYPE.PackedBit`),
+ * returns a copy of the bytes that are packed bits.
+ *
+ * Use `toBits` to get the unpacked bits.
+ *
+ * If the Binary is not a Vector, or the datatype is not PackedBit, an error is thrown.
+ */
+ toPackedBits(): Uint8Array;
+ /**
+ * If this Binary represents a Packed bit Vector (`binary.buffer[0] === Binary.VECTOR_TYPE.PackedBit`),
+ * returns a copy of the bit unpacked into a new Int8Array.
+ *
+ * Use `toPackedBits` to get the bits still in packed form.
+ *
+ * If the Binary is not a Vector, or the datatype is not PackedBit, an error is thrown.
+ */
+ toBits(): Int8Array;
+ /**
+ * Constructs a Binary representing an Int8 Vector.
+ * @param array - The array to store as a view on the Binary class
+ */
+ static fromInt8Array(array: Int8Array): Binary;
+ /** Constructs a Binary representing an Float32 Vector. */
+ static fromFloat32Array(array: Float32Array): Binary;
+ /**
+ * Constructs a Binary representing a packed bit Vector.
+ *
+ * Use `fromBits` to pack an array of 1s and 0s.
+ */
+ static fromPackedBits(array: Uint8Array, padding?: number): Binary;
+ /**
+ * Constructs a Binary representing an Packed Bit Vector.
+ * @param array - The array of 1s and 0s to pack into the Binary instance
+ */
+ static fromBits(bits: ArrayLike