some progress

This commit is contained in:
Jonas_Jones 2023-03-30 20:40:42 +02:00
parent aea93a5527
commit e3c15bd288
1388 changed files with 306946 additions and 68323 deletions

38
node_modules/mongoose/lib/schema/operators/bitwise.js generated vendored Normal file
View file

@ -0,0 +1,38 @@
/*!
* Module requirements.
*/
'use strict';
const CastError = require('../../error/cast');
/*!
* ignore
*/
function handleBitwiseOperator(val) {
const _this = this;
if (Array.isArray(val)) {
return val.map(function(v) {
return _castNumber(_this.path, v);
});
} else if (Buffer.isBuffer(val)) {
return val;
}
// Assume trying to cast to number
return _castNumber(_this.path, val);
}
/*!
* ignore
*/
function _castNumber(path, num) {
const v = Number(num);
if (isNaN(v)) {
throw new CastError('number', num, path);
}
return v;
}
module.exports = handleBitwiseOperator;

12
node_modules/mongoose/lib/schema/operators/exists.js generated vendored Normal file
View file

@ -0,0 +1,12 @@
'use strict';
const castBoolean = require('../../cast/boolean');
/*!
* ignore
*/
module.exports = function(val) {
const path = this != null ? this.path : null;
return castBoolean(val, path);
};

View file

@ -0,0 +1,107 @@
/*!
* Module requirements.
*/
'use strict';
const castArraysOfNumbers = require('./helpers').castArraysOfNumbers;
const castToNumber = require('./helpers').castToNumber;
/*!
* ignore
*/
exports.cast$geoIntersects = cast$geoIntersects;
exports.cast$near = cast$near;
exports.cast$within = cast$within;
function cast$near(val) {
const SchemaArray = require('../array');
if (Array.isArray(val)) {
castArraysOfNumbers(val, this);
return val;
}
_castMinMaxDistance(this, val);
if (val && val.$geometry) {
return cast$geometry(val, this);
}
if (!Array.isArray(val)) {
throw new TypeError('$near must be either an array or an object ' +
'with a $geometry property');
}
return SchemaArray.prototype.castForQuery.call(this, null, val);
}
function cast$geometry(val, self) {
switch (val.$geometry.type) {
case 'Polygon':
case 'LineString':
case 'Point':
castArraysOfNumbers(val.$geometry.coordinates, self);
break;
default:
// ignore unknowns
break;
}
_castMinMaxDistance(self, val);
return val;
}
function cast$within(val) {
_castMinMaxDistance(this, val);
if (val.$box || val.$polygon) {
const type = val.$box ? '$box' : '$polygon';
val[type].forEach(arr => {
if (!Array.isArray(arr)) {
const msg = 'Invalid $within $box argument. '
+ 'Expected an array, received ' + arr;
throw new TypeError(msg);
}
arr.forEach((v, i) => {
arr[i] = castToNumber.call(this, v);
});
});
} else if (val.$center || val.$centerSphere) {
const type = val.$center ? '$center' : '$centerSphere';
val[type].forEach((item, i) => {
if (Array.isArray(item)) {
item.forEach((v, j) => {
item[j] = castToNumber.call(this, v);
});
} else {
val[type][i] = castToNumber.call(this, item);
}
});
} else if (val.$geometry) {
cast$geometry(val, this);
}
return val;
}
function cast$geoIntersects(val) {
const geo = val.$geometry;
if (!geo) {
return;
}
cast$geometry(val, this);
return val;
}
function _castMinMaxDistance(self, val) {
if (val.$maxDistance) {
val.$maxDistance = castToNumber.call(self, val.$maxDistance);
}
if (val.$minDistance) {
val.$minDistance = castToNumber.call(self, val.$minDistance);
}
}

32
node_modules/mongoose/lib/schema/operators/helpers.js generated vendored Normal file
View file

@ -0,0 +1,32 @@
'use strict';
/*!
* Module requirements.
*/
const SchemaNumber = require('../number');
/*!
* ignore
*/
exports.castToNumber = castToNumber;
exports.castArraysOfNumbers = castArraysOfNumbers;
/*!
* ignore
*/
function castToNumber(val) {
return SchemaNumber.cast()(val);
}
function castArraysOfNumbers(arr, self) {
arr.forEach(function(v, i) {
if (Array.isArray(v)) {
castArraysOfNumbers(v, self);
} else {
arr[i] = castToNumber.call(self, v);
}
});
}

39
node_modules/mongoose/lib/schema/operators/text.js generated vendored Normal file
View file

@ -0,0 +1,39 @@
'use strict';
const CastError = require('../../error/cast');
const castBoolean = require('../../cast/boolean');
const castString = require('../../cast/string');
/**
* Casts val to an object suitable for `$text`. Throws an error if the object
* can't be casted.
*
* @param {Any} val value to cast
* @param {String} [path] path to associate with any errors that occured
* @return {Object} casted object
* @see https://www.mongodb.com/docs/manual/reference/operator/query/text/
* @api private
*/
module.exports = function(val, path) {
if (val == null || typeof val !== 'object') {
throw new CastError('$text', val, path);
}
if (val.$search != null) {
val.$search = castString(val.$search, path + '.$search');
}
if (val.$language != null) {
val.$language = castString(val.$language, path + '.$language');
}
if (val.$caseSensitive != null) {
val.$caseSensitive = castBoolean(val.$caseSensitive,
path + '.$castSensitive');
}
if (val.$diacriticSensitive != null) {
val.$diacriticSensitive = castBoolean(val.$diacriticSensitive,
path + '.$diacriticSensitive');
}
return val;
};

20
node_modules/mongoose/lib/schema/operators/type.js generated vendored Normal file
View file

@ -0,0 +1,20 @@
'use strict';
/*!
* ignore
*/
module.exports = function(val) {
if (Array.isArray(val)) {
if (!val.every(v => typeof v === 'number' || typeof v === 'string')) {
throw new Error('$type array values must be strings or numbers');
}
return val;
}
if (typeof val !== 'number' && typeof val !== 'string') {
throw new Error('$type parameter must be number, string, or array of numbers and strings');
}
return val;
};