[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: bson.ts
/* eslint-disable no-restricted-imports */ import { BSON, type DeserializeOptions, type SerializeOptions } from 'bson'; export { Binary, BSON, BSONError, BSONRegExp, BSONSymbol, BSONType, calculateObjectSize, Code, DBRef, Decimal128, deserialize, type DeserializeOptions, Document, Double, EJSON, EJSONOptions, Int32, Long, MaxKey, MinKey, NumberUtils, ObjectId, type ObjectIdLike, serialize, Timestamp, UUID } from 'bson'; /** @internal */ export type BSONElement = BSON.OnDemand['BSONElement']; export function parseToElementsToArray(bytes: Uint8Array, offset?: number): BSONElement[] { const res = BSON.onDemand.parseToElements(bytes, offset); return Array.isArray(res) ? res : [...res]; } export const getInt32LE = BSON.onDemand.NumberUtils.getInt32LE; export const getFloat64LE = BSON.onDemand.NumberUtils.getFloat64LE; export const getBigInt64LE = BSON.onDemand.NumberUtils.getBigInt64LE; export const toUTF8 = BSON.onDemand.ByteUtils.toUTF8; /** * BSON Serialization options. * @public */ export interface BSONSerializeOptions extends Omit<SerializeOptions, 'index'>, Omit< DeserializeOptions, | 'evalFunctions' | 'cacheFunctions' | 'cacheFunctionsCrc32' | 'allowObjectSmallerThanBufferSize' | 'index' | 'validation' > { /** * Enabling the raw option will return a [Node.js Buffer](https://nodejs.org/api/buffer.html) * which is allocated using [allocUnsafe API](https://nodejs.org/api/buffer.html#static-method-bufferallocunsafesize). * See this section from the [Node.js Docs here](https://nodejs.org/api/buffer.html#what-makes-bufferallocunsafe-and-bufferallocunsafeslow-unsafe) * for more detail about what "unsafe" refers to in this context. * If you need to maintain your own editable clone of the bytes returned for an extended life time of the process, it is recommended you allocate * your own buffer and clone the contents: * * @example * ```ts * const raw = await collection.findOne({}, { raw: true }); * const myBuffer = Buffer.alloc(raw.byteLength); * myBuffer.set(raw, 0); * // Only save and use `myBuffer` beyond this point * ``` * * @remarks * Please note there is a known limitation where this option cannot be used at the MongoClient level (see [NODE-3946](https://jira.mongodb.org/browse/NODE-3946)). * It does correctly work at `Db`, `Collection`, and per operation the same as other BSON options work. */ raw?: boolean; /** Enable utf8 validation when deserializing BSON documents. Defaults to true. */ enableUtf8Validation?: boolean; } export function pluckBSONSerializeOptions(options: BSONSerializeOptions): BSONSerializeOptions { const { fieldsAsRaw, useBigInt64, promoteValues, promoteBuffers, promoteLongs, serializeFunctions, ignoreUndefined, bsonRegExp, raw, enableUtf8Validation } = options; return { fieldsAsRaw, useBigInt64, promoteValues, promoteBuffers, promoteLongs, serializeFunctions, ignoreUndefined, bsonRegExp, raw, enableUtf8Validation }; } /** * Merge the given BSONSerializeOptions, preferring options over the parent's options, and * substituting defaults for values not set. * * @internal */ export function resolveBSONOptions( options?: BSONSerializeOptions, parent?: { bsonOptions?: BSONSerializeOptions } ): BSONSerializeOptions { const parentOptions = parent?.bsonOptions; return { raw: options?.raw ?? parentOptions?.raw ?? false, useBigInt64: options?.useBigInt64 ?? parentOptions?.useBigInt64 ?? false, promoteLongs: options?.promoteLongs ?? parentOptions?.promoteLongs ?? true, promoteValues: options?.promoteValues ?? parentOptions?.promoteValues ?? true, promoteBuffers: options?.promoteBuffers ?? parentOptions?.promoteBuffers ?? false, ignoreUndefined: options?.ignoreUndefined ?? parentOptions?.ignoreUndefined ?? false, bsonRegExp: options?.bsonRegExp ?? parentOptions?.bsonRegExp ?? false, serializeFunctions: options?.serializeFunctions ?? parentOptions?.serializeFunctions ?? false, fieldsAsRaw: options?.fieldsAsRaw ?? parentOptions?.fieldsAsRaw ?? {}, enableUtf8Validation: options?.enableUtf8Validation ?? parentOptions?.enableUtf8Validation ?? true }; } /** @internal */ export function parseUtf8ValidationOption(options?: { enableUtf8Validation?: boolean }): { utf8: { writeErrors: false } | false; } { const enableUtf8Validation = options?.enableUtf8Validation; if (enableUtf8Validation === false) { return { utf8: false }; } return { utf8: { writeErrors: false } }; }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium331.web-hosting.com
Server IP: 184.94.213.169
PHP Version: 8.1.34
Server Software: LiteSpeed
System: Linux premium331.web-hosting.com 4.18.0-553.80.1.lve.el8.x86_64 #1 SMP Wed Oct 22 19:29:36 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.82 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: livedhms
User ID (UID): 1344
Group ID (GID): 1349
Script Owner UID: 1344
Current Dir Owner: 1344