working rss feed to nostr publish
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.NoOpLogger = void 0;
|
||||
class NoOpLogger {
|
||||
trace() { }
|
||||
debug() { }
|
||||
info() { }
|
||||
warn() { }
|
||||
error() { }
|
||||
}
|
||||
exports.NoOpLogger = NoOpLogger;
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Client = void 0;
|
||||
const middleware_stack_1 = require("@smithy/middleware-stack");
|
||||
class Client {
|
||||
constructor(config) {
|
||||
this.middlewareStack = (0, middleware_stack_1.constructStack)();
|
||||
this.config = config;
|
||||
}
|
||||
send(command, optionsOrCb, cb) {
|
||||
const options = typeof optionsOrCb !== "function" ? optionsOrCb : undefined;
|
||||
const callback = typeof optionsOrCb === "function" ? optionsOrCb : cb;
|
||||
const handler = command.resolveMiddleware(this.middlewareStack, this.config, options);
|
||||
if (callback) {
|
||||
handler(command)
|
||||
.then((result) => callback(null, result.output), (err) => callback(err))
|
||||
.catch(() => { });
|
||||
}
|
||||
else {
|
||||
return handler(command).then((result) => result.output);
|
||||
}
|
||||
}
|
||||
destroy() {
|
||||
if (this.config.requestHandler.destroy)
|
||||
this.config.requestHandler.destroy();
|
||||
}
|
||||
}
|
||||
exports.Client = Client;
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.collectBody = void 0;
|
||||
const util_stream_1 = require("@smithy/util-stream");
|
||||
const collectBody = async (streamBody = new Uint8Array(), context) => {
|
||||
if (streamBody instanceof Uint8Array) {
|
||||
return util_stream_1.Uint8ArrayBlobAdapter.mutate(streamBody);
|
||||
}
|
||||
if (!streamBody) {
|
||||
return util_stream_1.Uint8ArrayBlobAdapter.mutate(new Uint8Array());
|
||||
}
|
||||
const fromContext = context.streamCollector(streamBody);
|
||||
return util_stream_1.Uint8ArrayBlobAdapter.mutate(await fromContext);
|
||||
};
|
||||
exports.collectBody = collectBody;
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Command = void 0;
|
||||
const middleware_stack_1 = require("@smithy/middleware-stack");
|
||||
class Command {
|
||||
constructor() {
|
||||
this.middlewareStack = (0, middleware_stack_1.constructStack)();
|
||||
}
|
||||
}
|
||||
exports.Command = Command;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SENSITIVE_STRING = void 0;
|
||||
exports.SENSITIVE_STRING = "***SensitiveInformation***";
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createAggregatedClient = void 0;
|
||||
const createAggregatedClient = (commands, Client) => {
|
||||
for (const command of Object.keys(commands)) {
|
||||
const CommandCtor = commands[command];
|
||||
const methodImpl = async function (args, optionsOrCb, cb) {
|
||||
const command = new CommandCtor(args);
|
||||
if (typeof optionsOrCb === "function") {
|
||||
this.send(command, optionsOrCb);
|
||||
}
|
||||
else if (typeof cb === "function") {
|
||||
if (typeof optionsOrCb !== "object")
|
||||
throw new Error(`Expected http options but got ${typeof optionsOrCb}`);
|
||||
this.send(command, optionsOrCb || {}, cb);
|
||||
}
|
||||
else {
|
||||
return this.send(command, optionsOrCb);
|
||||
}
|
||||
};
|
||||
const methodName = (command[0].toLowerCase() + command.slice(1)).replace(/Command$/, "");
|
||||
Client.prototype[methodName] = methodImpl;
|
||||
}
|
||||
};
|
||||
exports.createAggregatedClient = createAggregatedClient;
|
||||
+195
@@ -0,0 +1,195 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseEpochTimestamp = exports.parseRfc7231DateTime = exports.parseRfc3339DateTimeWithOffset = exports.parseRfc3339DateTime = exports.dateToUtcString = void 0;
|
||||
const parse_utils_1 = require("./parse-utils");
|
||||
const DAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
||||
const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
||||
function dateToUtcString(date) {
|
||||
const year = date.getUTCFullYear();
|
||||
const month = date.getUTCMonth();
|
||||
const dayOfWeek = date.getUTCDay();
|
||||
const dayOfMonthInt = date.getUTCDate();
|
||||
const hoursInt = date.getUTCHours();
|
||||
const minutesInt = date.getUTCMinutes();
|
||||
const secondsInt = date.getUTCSeconds();
|
||||
const dayOfMonthString = dayOfMonthInt < 10 ? `0${dayOfMonthInt}` : `${dayOfMonthInt}`;
|
||||
const hoursString = hoursInt < 10 ? `0${hoursInt}` : `${hoursInt}`;
|
||||
const minutesString = minutesInt < 10 ? `0${minutesInt}` : `${minutesInt}`;
|
||||
const secondsString = secondsInt < 10 ? `0${secondsInt}` : `${secondsInt}`;
|
||||
return `${DAYS[dayOfWeek]}, ${dayOfMonthString} ${MONTHS[month]} ${year} ${hoursString}:${minutesString}:${secondsString} GMT`;
|
||||
}
|
||||
exports.dateToUtcString = dateToUtcString;
|
||||
const RFC3339 = new RegExp(/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?[zZ]$/);
|
||||
const parseRfc3339DateTime = (value) => {
|
||||
if (value === null || value === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
if (typeof value !== "string") {
|
||||
throw new TypeError("RFC-3339 date-times must be expressed as strings");
|
||||
}
|
||||
const match = RFC3339.exec(value);
|
||||
if (!match) {
|
||||
throw new TypeError("Invalid RFC-3339 date-time value");
|
||||
}
|
||||
const [_, yearStr, monthStr, dayStr, hours, minutes, seconds, fractionalMilliseconds] = match;
|
||||
const year = (0, parse_utils_1.strictParseShort)(stripLeadingZeroes(yearStr));
|
||||
const month = parseDateValue(monthStr, "month", 1, 12);
|
||||
const day = parseDateValue(dayStr, "day", 1, 31);
|
||||
return buildDate(year, month, day, { hours, minutes, seconds, fractionalMilliseconds });
|
||||
};
|
||||
exports.parseRfc3339DateTime = parseRfc3339DateTime;
|
||||
const RFC3339_WITH_OFFSET = new RegExp(/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?(([-+]\d{2}\:\d{2})|[zZ])$/);
|
||||
const parseRfc3339DateTimeWithOffset = (value) => {
|
||||
if (value === null || value === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
if (typeof value !== "string") {
|
||||
throw new TypeError("RFC-3339 date-times must be expressed as strings");
|
||||
}
|
||||
const match = RFC3339_WITH_OFFSET.exec(value);
|
||||
if (!match) {
|
||||
throw new TypeError("Invalid RFC-3339 date-time value");
|
||||
}
|
||||
const [_, yearStr, monthStr, dayStr, hours, minutes, seconds, fractionalMilliseconds, offsetStr] = match;
|
||||
const year = (0, parse_utils_1.strictParseShort)(stripLeadingZeroes(yearStr));
|
||||
const month = parseDateValue(monthStr, "month", 1, 12);
|
||||
const day = parseDateValue(dayStr, "day", 1, 31);
|
||||
const date = buildDate(year, month, day, { hours, minutes, seconds, fractionalMilliseconds });
|
||||
if (offsetStr.toUpperCase() != "Z") {
|
||||
date.setTime(date.getTime() - parseOffsetToMilliseconds(offsetStr));
|
||||
}
|
||||
return date;
|
||||
};
|
||||
exports.parseRfc3339DateTimeWithOffset = parseRfc3339DateTimeWithOffset;
|
||||
const IMF_FIXDATE = new RegExp(/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d{2}) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d{1,2}):(\d{2}):(\d{2})(?:\.(\d+))? GMT$/);
|
||||
const RFC_850_DATE = new RegExp(/^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d{2})-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d{2}) (\d{1,2}):(\d{2}):(\d{2})(?:\.(\d+))? GMT$/);
|
||||
const ASC_TIME = new RegExp(/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( [1-9]|\d{2}) (\d{1,2}):(\d{2}):(\d{2})(?:\.(\d+))? (\d{4})$/);
|
||||
const parseRfc7231DateTime = (value) => {
|
||||
if (value === null || value === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
if (typeof value !== "string") {
|
||||
throw new TypeError("RFC-7231 date-times must be expressed as strings");
|
||||
}
|
||||
let match = IMF_FIXDATE.exec(value);
|
||||
if (match) {
|
||||
const [_, dayStr, monthStr, yearStr, hours, minutes, seconds, fractionalMilliseconds] = match;
|
||||
return buildDate((0, parse_utils_1.strictParseShort)(stripLeadingZeroes(yearStr)), parseMonthByShortName(monthStr), parseDateValue(dayStr, "day", 1, 31), { hours, minutes, seconds, fractionalMilliseconds });
|
||||
}
|
||||
match = RFC_850_DATE.exec(value);
|
||||
if (match) {
|
||||
const [_, dayStr, monthStr, yearStr, hours, minutes, seconds, fractionalMilliseconds] = match;
|
||||
return adjustRfc850Year(buildDate(parseTwoDigitYear(yearStr), parseMonthByShortName(monthStr), parseDateValue(dayStr, "day", 1, 31), {
|
||||
hours,
|
||||
minutes,
|
||||
seconds,
|
||||
fractionalMilliseconds,
|
||||
}));
|
||||
}
|
||||
match = ASC_TIME.exec(value);
|
||||
if (match) {
|
||||
const [_, monthStr, dayStr, hours, minutes, seconds, fractionalMilliseconds, yearStr] = match;
|
||||
return buildDate((0, parse_utils_1.strictParseShort)(stripLeadingZeroes(yearStr)), parseMonthByShortName(monthStr), parseDateValue(dayStr.trimLeft(), "day", 1, 31), { hours, minutes, seconds, fractionalMilliseconds });
|
||||
}
|
||||
throw new TypeError("Invalid RFC-7231 date-time value");
|
||||
};
|
||||
exports.parseRfc7231DateTime = parseRfc7231DateTime;
|
||||
const parseEpochTimestamp = (value) => {
|
||||
if (value === null || value === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
let valueAsDouble;
|
||||
if (typeof value === "number") {
|
||||
valueAsDouble = value;
|
||||
}
|
||||
else if (typeof value === "string") {
|
||||
valueAsDouble = (0, parse_utils_1.strictParseDouble)(value);
|
||||
}
|
||||
else {
|
||||
throw new TypeError("Epoch timestamps must be expressed as floating point numbers or their string representation");
|
||||
}
|
||||
if (Number.isNaN(valueAsDouble) || valueAsDouble === Infinity || valueAsDouble === -Infinity) {
|
||||
throw new TypeError("Epoch timestamps must be valid, non-Infinite, non-NaN numerics");
|
||||
}
|
||||
return new Date(Math.round(valueAsDouble * 1000));
|
||||
};
|
||||
exports.parseEpochTimestamp = parseEpochTimestamp;
|
||||
const buildDate = (year, month, day, time) => {
|
||||
const adjustedMonth = month - 1;
|
||||
validateDayOfMonth(year, adjustedMonth, day);
|
||||
return new Date(Date.UTC(year, adjustedMonth, day, parseDateValue(time.hours, "hour", 0, 23), parseDateValue(time.minutes, "minute", 0, 59), parseDateValue(time.seconds, "seconds", 0, 60), parseMilliseconds(time.fractionalMilliseconds)));
|
||||
};
|
||||
const parseTwoDigitYear = (value) => {
|
||||
const thisYear = new Date().getUTCFullYear();
|
||||
const valueInThisCentury = Math.floor(thisYear / 100) * 100 + (0, parse_utils_1.strictParseShort)(stripLeadingZeroes(value));
|
||||
if (valueInThisCentury < thisYear) {
|
||||
return valueInThisCentury + 100;
|
||||
}
|
||||
return valueInThisCentury;
|
||||
};
|
||||
const FIFTY_YEARS_IN_MILLIS = 50 * 365 * 24 * 60 * 60 * 1000;
|
||||
const adjustRfc850Year = (input) => {
|
||||
if (input.getTime() - new Date().getTime() > FIFTY_YEARS_IN_MILLIS) {
|
||||
return new Date(Date.UTC(input.getUTCFullYear() - 100, input.getUTCMonth(), input.getUTCDate(), input.getUTCHours(), input.getUTCMinutes(), input.getUTCSeconds(), input.getUTCMilliseconds()));
|
||||
}
|
||||
return input;
|
||||
};
|
||||
const parseMonthByShortName = (value) => {
|
||||
const monthIdx = MONTHS.indexOf(value);
|
||||
if (monthIdx < 0) {
|
||||
throw new TypeError(`Invalid month: ${value}`);
|
||||
}
|
||||
return monthIdx + 1;
|
||||
};
|
||||
const DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
||||
const validateDayOfMonth = (year, month, day) => {
|
||||
let maxDays = DAYS_IN_MONTH[month];
|
||||
if (month === 1 && isLeapYear(year)) {
|
||||
maxDays = 29;
|
||||
}
|
||||
if (day > maxDays) {
|
||||
throw new TypeError(`Invalid day for ${MONTHS[month]} in ${year}: ${day}`);
|
||||
}
|
||||
};
|
||||
const isLeapYear = (year) => {
|
||||
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
||||
};
|
||||
const parseDateValue = (value, type, lower, upper) => {
|
||||
const dateVal = (0, parse_utils_1.strictParseByte)(stripLeadingZeroes(value));
|
||||
if (dateVal < lower || dateVal > upper) {
|
||||
throw new TypeError(`${type} must be between ${lower} and ${upper}, inclusive`);
|
||||
}
|
||||
return dateVal;
|
||||
};
|
||||
const parseMilliseconds = (value) => {
|
||||
if (value === null || value === undefined) {
|
||||
return 0;
|
||||
}
|
||||
return (0, parse_utils_1.strictParseFloat32)("0." + value) * 1000;
|
||||
};
|
||||
const parseOffsetToMilliseconds = (value) => {
|
||||
const directionStr = value[0];
|
||||
let direction = 1;
|
||||
if (directionStr == "+") {
|
||||
direction = 1;
|
||||
}
|
||||
else if (directionStr == "-") {
|
||||
direction = -1;
|
||||
}
|
||||
else {
|
||||
throw new TypeError(`Offset direction, ${directionStr}, must be "+" or "-"`);
|
||||
}
|
||||
const hour = Number(value.substring(1, 3));
|
||||
const minute = Number(value.substring(4, 6));
|
||||
return direction * (hour * 60 + minute) * 60 * 1000;
|
||||
};
|
||||
const stripLeadingZeroes = (value) => {
|
||||
let idx = 0;
|
||||
while (idx < value.length - 1 && value.charAt(idx) === "0") {
|
||||
idx++;
|
||||
}
|
||||
if (idx === 0) {
|
||||
return value;
|
||||
}
|
||||
return value.slice(idx);
|
||||
};
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.withBaseException = exports.throwDefaultError = void 0;
|
||||
const exceptions_1 = require("./exceptions");
|
||||
const throwDefaultError = ({ output, parsedBody, exceptionCtor, errorCode }) => {
|
||||
const $metadata = deserializeMetadata(output);
|
||||
const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined;
|
||||
const response = new exceptionCtor({
|
||||
name: (parsedBody === null || parsedBody === void 0 ? void 0 : parsedBody.code) || (parsedBody === null || parsedBody === void 0 ? void 0 : parsedBody.Code) || errorCode || statusCode || "UnknownError",
|
||||
$fault: "client",
|
||||
$metadata,
|
||||
});
|
||||
throw (0, exceptions_1.decorateServiceException)(response, parsedBody);
|
||||
};
|
||||
exports.throwDefaultError = throwDefaultError;
|
||||
const withBaseException = (ExceptionCtor) => {
|
||||
return ({ output, parsedBody, errorCode }) => {
|
||||
(0, exports.throwDefaultError)({ output, parsedBody, exceptionCtor: ExceptionCtor, errorCode });
|
||||
};
|
||||
};
|
||||
exports.withBaseException = withBaseException;
|
||||
const deserializeMetadata = (output) => {
|
||||
var _a, _b;
|
||||
return ({
|
||||
httpStatusCode: output.statusCode,
|
||||
requestId: (_b = (_a = output.headers["x-amzn-requestid"]) !== null && _a !== void 0 ? _a : output.headers["x-amzn-request-id"]) !== null && _b !== void 0 ? _b : output.headers["x-amz-request-id"],
|
||||
extendedRequestId: output.headers["x-amz-id-2"],
|
||||
cfId: output.headers["x-amz-cf-id"],
|
||||
});
|
||||
};
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.loadConfigsForDefaultMode = void 0;
|
||||
const loadConfigsForDefaultMode = (mode) => {
|
||||
switch (mode) {
|
||||
case "standard":
|
||||
return {
|
||||
retryMode: "standard",
|
||||
connectionTimeout: 3100,
|
||||
};
|
||||
case "in-region":
|
||||
return {
|
||||
retryMode: "standard",
|
||||
connectionTimeout: 1100,
|
||||
};
|
||||
case "cross-region":
|
||||
return {
|
||||
retryMode: "standard",
|
||||
connectionTimeout: 3100,
|
||||
};
|
||||
case "mobile":
|
||||
return {
|
||||
retryMode: "standard",
|
||||
connectionTimeout: 30000,
|
||||
};
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
};
|
||||
exports.loadConfigsForDefaultMode = loadConfigsForDefaultMode;
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.emitWarningIfUnsupportedVersion = void 0;
|
||||
let warningEmitted = false;
|
||||
const emitWarningIfUnsupportedVersion = (version) => {
|
||||
if (version && !warningEmitted && parseInt(version.substring(1, version.indexOf("."))) < 14) {
|
||||
warningEmitted = true;
|
||||
}
|
||||
};
|
||||
exports.emitWarningIfUnsupportedVersion = emitWarningIfUnsupportedVersion;
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.decorateServiceException = exports.ServiceException = void 0;
|
||||
class ServiceException extends Error {
|
||||
constructor(options) {
|
||||
super(options.message);
|
||||
Object.setPrototypeOf(this, ServiceException.prototype);
|
||||
this.name = options.name;
|
||||
this.$fault = options.$fault;
|
||||
this.$metadata = options.$metadata;
|
||||
}
|
||||
}
|
||||
exports.ServiceException = ServiceException;
|
||||
const decorateServiceException = (exception, additions = {}) => {
|
||||
Object.entries(additions)
|
||||
.filter(([, v]) => v !== undefined)
|
||||
.forEach(([k, v]) => {
|
||||
if (exception[k] == undefined || exception[k] === "") {
|
||||
exception[k] = v;
|
||||
}
|
||||
});
|
||||
const message = exception.message || exception.Message || "UnknownError";
|
||||
exception.message = message;
|
||||
delete exception.Message;
|
||||
return exception;
|
||||
};
|
||||
exports.decorateServiceException = decorateServiceException;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.extendedEncodeURIComponent = void 0;
|
||||
function extendedEncodeURIComponent(str) {
|
||||
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
|
||||
return "%" + c.charCodeAt(0).toString(16).toUpperCase();
|
||||
});
|
||||
}
|
||||
exports.extendedEncodeURIComponent = extendedEncodeURIComponent;
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.resolveChecksumRuntimeConfig = exports.getChecksumConfiguration = exports.AlgorithmId = void 0;
|
||||
const types_1 = require("@smithy/types");
|
||||
Object.defineProperty(exports, "AlgorithmId", { enumerable: true, get: function () { return types_1.AlgorithmId; } });
|
||||
const getChecksumConfiguration = (runtimeConfig) => {
|
||||
const checksumAlgorithms = [];
|
||||
for (const id in types_1.AlgorithmId) {
|
||||
const algorithmId = types_1.AlgorithmId[id];
|
||||
if (runtimeConfig[algorithmId] === undefined) {
|
||||
continue;
|
||||
}
|
||||
checksumAlgorithms.push({
|
||||
algorithmId: () => algorithmId,
|
||||
checksumConstructor: () => runtimeConfig[algorithmId],
|
||||
});
|
||||
}
|
||||
return {
|
||||
_checksumAlgorithms: checksumAlgorithms,
|
||||
addChecksumAlgorithm(algo) {
|
||||
this._checksumAlgorithms.push(algo);
|
||||
},
|
||||
checksumAlgorithms() {
|
||||
return this._checksumAlgorithms;
|
||||
},
|
||||
};
|
||||
};
|
||||
exports.getChecksumConfiguration = getChecksumConfiguration;
|
||||
const resolveChecksumRuntimeConfig = (clientConfig) => {
|
||||
const runtimeConfig = {};
|
||||
clientConfig.checksumAlgorithms().forEach((checksumAlgorithm) => {
|
||||
runtimeConfig[checksumAlgorithm.algorithmId()] = checksumAlgorithm.checksumConstructor();
|
||||
});
|
||||
return runtimeConfig;
|
||||
};
|
||||
exports.resolveChecksumRuntimeConfig = resolveChecksumRuntimeConfig;
|
||||
Generated
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.resolveDefaultRuntimeConfig = exports.getDefaultClientConfiguration = exports.getDefaultExtensionConfiguration = void 0;
|
||||
const checksum_1 = require("./checksum");
|
||||
const retry_1 = require("./retry");
|
||||
const getDefaultExtensionConfiguration = (runtimeConfig) => {
|
||||
return {
|
||||
...(0, checksum_1.getChecksumConfiguration)(runtimeConfig),
|
||||
...(0, retry_1.getRetryConfiguration)(runtimeConfig),
|
||||
};
|
||||
};
|
||||
exports.getDefaultExtensionConfiguration = getDefaultExtensionConfiguration;
|
||||
exports.getDefaultClientConfiguration = exports.getDefaultExtensionConfiguration;
|
||||
const resolveDefaultRuntimeConfig = (config) => {
|
||||
return {
|
||||
...(0, checksum_1.resolveChecksumRuntimeConfig)(config),
|
||||
...(0, retry_1.resolveRetryRuntimeConfig)(config),
|
||||
};
|
||||
};
|
||||
exports.resolveDefaultRuntimeConfig = resolveDefaultRuntimeConfig;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tslib_1 = require("tslib");
|
||||
tslib_1.__exportStar(require("./defaultExtensionConfiguration"), exports);
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.resolveRetryRuntimeConfig = exports.getRetryConfiguration = void 0;
|
||||
const getRetryConfiguration = (runtimeConfig) => {
|
||||
let _retryStrategy = runtimeConfig.retryStrategy;
|
||||
return {
|
||||
setRetryStrategy(retryStrategy) {
|
||||
_retryStrategy = retryStrategy;
|
||||
},
|
||||
retryStrategy() {
|
||||
return _retryStrategy;
|
||||
},
|
||||
};
|
||||
};
|
||||
exports.getRetryConfiguration = getRetryConfiguration;
|
||||
const resolveRetryRuntimeConfig = (retryStrategyConfiguration) => {
|
||||
const runtimeConfig = {};
|
||||
runtimeConfig.retryStrategy = retryStrategyConfiguration.retryStrategy();
|
||||
return runtimeConfig;
|
||||
};
|
||||
exports.resolveRetryRuntimeConfig = resolveRetryRuntimeConfig;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getArrayIfSingleItem = void 0;
|
||||
const getArrayIfSingleItem = (mayBeArray) => Array.isArray(mayBeArray) ? mayBeArray : [mayBeArray];
|
||||
exports.getArrayIfSingleItem = getArrayIfSingleItem;
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getValueFromTextNode = void 0;
|
||||
const getValueFromTextNode = (obj) => {
|
||||
const textNodeName = "#text";
|
||||
for (const key in obj) {
|
||||
if (obj.hasOwnProperty(key) && obj[key][textNodeName] !== undefined) {
|
||||
obj[key] = obj[key][textNodeName];
|
||||
}
|
||||
else if (typeof obj[key] === "object" && obj[key] !== null) {
|
||||
obj[key] = (0, exports.getValueFromTextNode)(obj[key]);
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
exports.getValueFromTextNode = getValueFromTextNode;
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tslib_1 = require("tslib");
|
||||
tslib_1.__exportStar(require("./NoOpLogger"), exports);
|
||||
tslib_1.__exportStar(require("./client"), exports);
|
||||
tslib_1.__exportStar(require("./collect-stream-body"), exports);
|
||||
tslib_1.__exportStar(require("./command"), exports);
|
||||
tslib_1.__exportStar(require("./constants"), exports);
|
||||
tslib_1.__exportStar(require("./create-aggregated-client"), exports);
|
||||
tslib_1.__exportStar(require("./date-utils"), exports);
|
||||
tslib_1.__exportStar(require("./default-error-handler"), exports);
|
||||
tslib_1.__exportStar(require("./defaults-mode"), exports);
|
||||
tslib_1.__exportStar(require("./emitWarningIfUnsupportedVersion"), exports);
|
||||
tslib_1.__exportStar(require("./extensions"), exports);
|
||||
tslib_1.__exportStar(require("./exceptions"), exports);
|
||||
tslib_1.__exportStar(require("./extended-encode-uri-component"), exports);
|
||||
tslib_1.__exportStar(require("./get-array-if-single-item"), exports);
|
||||
tslib_1.__exportStar(require("./get-value-from-text-node"), exports);
|
||||
tslib_1.__exportStar(require("./lazy-json"), exports);
|
||||
tslib_1.__exportStar(require("./object-mapping"), exports);
|
||||
tslib_1.__exportStar(require("./parse-utils"), exports);
|
||||
tslib_1.__exportStar(require("./resolve-path"), exports);
|
||||
tslib_1.__exportStar(require("./ser-utils"), exports);
|
||||
tslib_1.__exportStar(require("./serde-json"), exports);
|
||||
tslib_1.__exportStar(require("./split-every"), exports);
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.LazyJsonString = exports.StringWrapper = void 0;
|
||||
const StringWrapper = function () {
|
||||
const Class = Object.getPrototypeOf(this).constructor;
|
||||
const Constructor = Function.bind.apply(String, [null, ...arguments]);
|
||||
const instance = new Constructor();
|
||||
Object.setPrototypeOf(instance, Class.prototype);
|
||||
return instance;
|
||||
};
|
||||
exports.StringWrapper = StringWrapper;
|
||||
exports.StringWrapper.prototype = Object.create(String.prototype, {
|
||||
constructor: {
|
||||
value: exports.StringWrapper,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true,
|
||||
},
|
||||
});
|
||||
Object.setPrototypeOf(exports.StringWrapper, String);
|
||||
class LazyJsonString extends exports.StringWrapper {
|
||||
deserializeJSON() {
|
||||
return JSON.parse(super.toString());
|
||||
}
|
||||
toJSON() {
|
||||
return super.toString();
|
||||
}
|
||||
static fromObject(object) {
|
||||
if (object instanceof LazyJsonString) {
|
||||
return object;
|
||||
}
|
||||
else if (object instanceof String || typeof object === "string") {
|
||||
return new LazyJsonString(object);
|
||||
}
|
||||
return new LazyJsonString(JSON.stringify(object));
|
||||
}
|
||||
}
|
||||
exports.LazyJsonString = LazyJsonString;
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.take = exports.convertMap = exports.map = void 0;
|
||||
function map(arg0, arg1, arg2) {
|
||||
let target;
|
||||
let filter;
|
||||
let instructions;
|
||||
if (typeof arg1 === "undefined" && typeof arg2 === "undefined") {
|
||||
target = {};
|
||||
instructions = arg0;
|
||||
}
|
||||
else {
|
||||
target = arg0;
|
||||
if (typeof arg1 === "function") {
|
||||
filter = arg1;
|
||||
instructions = arg2;
|
||||
return mapWithFilter(target, filter, instructions);
|
||||
}
|
||||
else {
|
||||
instructions = arg1;
|
||||
}
|
||||
}
|
||||
for (const key of Object.keys(instructions)) {
|
||||
if (!Array.isArray(instructions[key])) {
|
||||
target[key] = instructions[key];
|
||||
continue;
|
||||
}
|
||||
applyInstruction(target, null, instructions, key);
|
||||
}
|
||||
return target;
|
||||
}
|
||||
exports.map = map;
|
||||
const convertMap = (target) => {
|
||||
const output = {};
|
||||
for (const [k, v] of Object.entries(target || {})) {
|
||||
output[k] = [, v];
|
||||
}
|
||||
return output;
|
||||
};
|
||||
exports.convertMap = convertMap;
|
||||
const take = (source, instructions) => {
|
||||
const out = {};
|
||||
for (const key in instructions) {
|
||||
applyInstruction(out, source, instructions, key);
|
||||
}
|
||||
return out;
|
||||
};
|
||||
exports.take = take;
|
||||
const mapWithFilter = (target, filter, instructions) => {
|
||||
return map(target, Object.entries(instructions).reduce((_instructions, [key, value]) => {
|
||||
if (Array.isArray(value)) {
|
||||
_instructions[key] = value;
|
||||
}
|
||||
else {
|
||||
if (typeof value === "function") {
|
||||
_instructions[key] = [filter, value()];
|
||||
}
|
||||
else {
|
||||
_instructions[key] = [filter, value];
|
||||
}
|
||||
}
|
||||
return _instructions;
|
||||
}, {}));
|
||||
};
|
||||
const applyInstruction = (target, source, instructions, targetKey) => {
|
||||
if (source !== null) {
|
||||
let instruction = instructions[targetKey];
|
||||
if (typeof instruction === "function") {
|
||||
instruction = [, instruction];
|
||||
}
|
||||
const [filter = nonNullish, valueFn = pass, sourceKey = targetKey] = instruction;
|
||||
if ((typeof filter === "function" && filter(source[sourceKey])) || (typeof filter !== "function" && !!filter)) {
|
||||
target[targetKey] = valueFn(source[sourceKey]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
let [filter, value] = instructions[targetKey];
|
||||
if (typeof value === "function") {
|
||||
let _value;
|
||||
const defaultFilterPassed = filter === undefined && (_value = value()) != null;
|
||||
const customFilterPassed = (typeof filter === "function" && !!filter(void 0)) || (typeof filter !== "function" && !!filter);
|
||||
if (defaultFilterPassed) {
|
||||
target[targetKey] = _value;
|
||||
}
|
||||
else if (customFilterPassed) {
|
||||
target[targetKey] = value();
|
||||
}
|
||||
}
|
||||
else {
|
||||
const defaultFilterPassed = filter === undefined && value != null;
|
||||
const customFilterPassed = (typeof filter === "function" && !!filter(value)) || (typeof filter !== "function" && !!filter);
|
||||
if (defaultFilterPassed || customFilterPassed) {
|
||||
target[targetKey] = value;
|
||||
}
|
||||
}
|
||||
};
|
||||
const nonNullish = (_) => _ != null;
|
||||
const pass = (_) => _;
|
||||
+253
@@ -0,0 +1,253 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.logger = exports.strictParseByte = exports.strictParseShort = exports.strictParseInt32 = exports.strictParseInt = exports.strictParseLong = exports.limitedParseFloat32 = exports.limitedParseFloat = exports.handleFloat = exports.limitedParseDouble = exports.strictParseFloat32 = exports.strictParseFloat = exports.strictParseDouble = exports.expectUnion = exports.expectString = exports.expectObject = exports.expectNonNull = exports.expectByte = exports.expectShort = exports.expectInt32 = exports.expectInt = exports.expectLong = exports.expectFloat32 = exports.expectNumber = exports.expectBoolean = exports.parseBoolean = void 0;
|
||||
const parseBoolean = (value) => {
|
||||
switch (value) {
|
||||
case "true":
|
||||
return true;
|
||||
case "false":
|
||||
return false;
|
||||
default:
|
||||
throw new Error(`Unable to parse boolean value "${value}"`);
|
||||
}
|
||||
};
|
||||
exports.parseBoolean = parseBoolean;
|
||||
const expectBoolean = (value) => {
|
||||
if (value === null || value === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
if (typeof value === "number") {
|
||||
if (value === 0 || value === 1) {
|
||||
exports.logger.warn(stackTraceWarning(`Expected boolean, got ${typeof value}: ${value}`));
|
||||
}
|
||||
if (value === 0) {
|
||||
return false;
|
||||
}
|
||||
if (value === 1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (typeof value === "string") {
|
||||
const lower = value.toLowerCase();
|
||||
if (lower === "false" || lower === "true") {
|
||||
exports.logger.warn(stackTraceWarning(`Expected boolean, got ${typeof value}: ${value}`));
|
||||
}
|
||||
if (lower === "false") {
|
||||
return false;
|
||||
}
|
||||
if (lower === "true") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (typeof value === "boolean") {
|
||||
return value;
|
||||
}
|
||||
throw new TypeError(`Expected boolean, got ${typeof value}: ${value}`);
|
||||
};
|
||||
exports.expectBoolean = expectBoolean;
|
||||
const expectNumber = (value) => {
|
||||
if (value === null || value === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
if (typeof value === "string") {
|
||||
const parsed = parseFloat(value);
|
||||
if (!Number.isNaN(parsed)) {
|
||||
if (String(parsed) !== String(value)) {
|
||||
exports.logger.warn(stackTraceWarning(`Expected number but observed string: ${value}`));
|
||||
}
|
||||
return parsed;
|
||||
}
|
||||
}
|
||||
if (typeof value === "number") {
|
||||
return value;
|
||||
}
|
||||
throw new TypeError(`Expected number, got ${typeof value}: ${value}`);
|
||||
};
|
||||
exports.expectNumber = expectNumber;
|
||||
const MAX_FLOAT = Math.ceil(2 ** 127 * (2 - 2 ** -23));
|
||||
const expectFloat32 = (value) => {
|
||||
const expected = (0, exports.expectNumber)(value);
|
||||
if (expected !== undefined && !Number.isNaN(expected) && expected !== Infinity && expected !== -Infinity) {
|
||||
if (Math.abs(expected) > MAX_FLOAT) {
|
||||
throw new TypeError(`Expected 32-bit float, got ${value}`);
|
||||
}
|
||||
}
|
||||
return expected;
|
||||
};
|
||||
exports.expectFloat32 = expectFloat32;
|
||||
const expectLong = (value) => {
|
||||
if (value === null || value === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
if (Number.isInteger(value) && !Number.isNaN(value)) {
|
||||
return value;
|
||||
}
|
||||
throw new TypeError(`Expected integer, got ${typeof value}: ${value}`);
|
||||
};
|
||||
exports.expectLong = expectLong;
|
||||
exports.expectInt = exports.expectLong;
|
||||
const expectInt32 = (value) => expectSizedInt(value, 32);
|
||||
exports.expectInt32 = expectInt32;
|
||||
const expectShort = (value) => expectSizedInt(value, 16);
|
||||
exports.expectShort = expectShort;
|
||||
const expectByte = (value) => expectSizedInt(value, 8);
|
||||
exports.expectByte = expectByte;
|
||||
const expectSizedInt = (value, size) => {
|
||||
const expected = (0, exports.expectLong)(value);
|
||||
if (expected !== undefined && castInt(expected, size) !== expected) {
|
||||
throw new TypeError(`Expected ${size}-bit integer, got ${value}`);
|
||||
}
|
||||
return expected;
|
||||
};
|
||||
const castInt = (value, size) => {
|
||||
switch (size) {
|
||||
case 32:
|
||||
return Int32Array.of(value)[0];
|
||||
case 16:
|
||||
return Int16Array.of(value)[0];
|
||||
case 8:
|
||||
return Int8Array.of(value)[0];
|
||||
}
|
||||
};
|
||||
const expectNonNull = (value, location) => {
|
||||
if (value === null || value === undefined) {
|
||||
if (location) {
|
||||
throw new TypeError(`Expected a non-null value for ${location}`);
|
||||
}
|
||||
throw new TypeError("Expected a non-null value");
|
||||
}
|
||||
return value;
|
||||
};
|
||||
exports.expectNonNull = expectNonNull;
|
||||
const expectObject = (value) => {
|
||||
if (value === null || value === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
if (typeof value === "object" && !Array.isArray(value)) {
|
||||
return value;
|
||||
}
|
||||
const receivedType = Array.isArray(value) ? "array" : typeof value;
|
||||
throw new TypeError(`Expected object, got ${receivedType}: ${value}`);
|
||||
};
|
||||
exports.expectObject = expectObject;
|
||||
const expectString = (value) => {
|
||||
if (value === null || value === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
if (typeof value === "string") {
|
||||
return value;
|
||||
}
|
||||
if (["boolean", "number", "bigint"].includes(typeof value)) {
|
||||
exports.logger.warn(stackTraceWarning(`Expected string, got ${typeof value}: ${value}`));
|
||||
return String(value);
|
||||
}
|
||||
throw new TypeError(`Expected string, got ${typeof value}: ${value}`);
|
||||
};
|
||||
exports.expectString = expectString;
|
||||
const expectUnion = (value) => {
|
||||
if (value === null || value === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
const asObject = (0, exports.expectObject)(value);
|
||||
const setKeys = Object.entries(asObject)
|
||||
.filter(([, v]) => v != null)
|
||||
.map(([k]) => k);
|
||||
if (setKeys.length === 0) {
|
||||
throw new TypeError(`Unions must have exactly one non-null member. None were found.`);
|
||||
}
|
||||
if (setKeys.length > 1) {
|
||||
throw new TypeError(`Unions must have exactly one non-null member. Keys ${setKeys} were not null.`);
|
||||
}
|
||||
return asObject;
|
||||
};
|
||||
exports.expectUnion = expectUnion;
|
||||
const strictParseDouble = (value) => {
|
||||
if (typeof value == "string") {
|
||||
return (0, exports.expectNumber)(parseNumber(value));
|
||||
}
|
||||
return (0, exports.expectNumber)(value);
|
||||
};
|
||||
exports.strictParseDouble = strictParseDouble;
|
||||
exports.strictParseFloat = exports.strictParseDouble;
|
||||
const strictParseFloat32 = (value) => {
|
||||
if (typeof value == "string") {
|
||||
return (0, exports.expectFloat32)(parseNumber(value));
|
||||
}
|
||||
return (0, exports.expectFloat32)(value);
|
||||
};
|
||||
exports.strictParseFloat32 = strictParseFloat32;
|
||||
const NUMBER_REGEX = /(-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?)|(-?Infinity)|(NaN)/g;
|
||||
const parseNumber = (value) => {
|
||||
const matches = value.match(NUMBER_REGEX);
|
||||
if (matches === null || matches[0].length !== value.length) {
|
||||
throw new TypeError(`Expected real number, got implicit NaN`);
|
||||
}
|
||||
return parseFloat(value);
|
||||
};
|
||||
const limitedParseDouble = (value) => {
|
||||
if (typeof value == "string") {
|
||||
return parseFloatString(value);
|
||||
}
|
||||
return (0, exports.expectNumber)(value);
|
||||
};
|
||||
exports.limitedParseDouble = limitedParseDouble;
|
||||
exports.handleFloat = exports.limitedParseDouble;
|
||||
exports.limitedParseFloat = exports.limitedParseDouble;
|
||||
const limitedParseFloat32 = (value) => {
|
||||
if (typeof value == "string") {
|
||||
return parseFloatString(value);
|
||||
}
|
||||
return (0, exports.expectFloat32)(value);
|
||||
};
|
||||
exports.limitedParseFloat32 = limitedParseFloat32;
|
||||
const parseFloatString = (value) => {
|
||||
switch (value) {
|
||||
case "NaN":
|
||||
return NaN;
|
||||
case "Infinity":
|
||||
return Infinity;
|
||||
case "-Infinity":
|
||||
return -Infinity;
|
||||
default:
|
||||
throw new Error(`Unable to parse float value: ${value}`);
|
||||
}
|
||||
};
|
||||
const strictParseLong = (value) => {
|
||||
if (typeof value === "string") {
|
||||
return (0, exports.expectLong)(parseNumber(value));
|
||||
}
|
||||
return (0, exports.expectLong)(value);
|
||||
};
|
||||
exports.strictParseLong = strictParseLong;
|
||||
exports.strictParseInt = exports.strictParseLong;
|
||||
const strictParseInt32 = (value) => {
|
||||
if (typeof value === "string") {
|
||||
return (0, exports.expectInt32)(parseNumber(value));
|
||||
}
|
||||
return (0, exports.expectInt32)(value);
|
||||
};
|
||||
exports.strictParseInt32 = strictParseInt32;
|
||||
const strictParseShort = (value) => {
|
||||
if (typeof value === "string") {
|
||||
return (0, exports.expectShort)(parseNumber(value));
|
||||
}
|
||||
return (0, exports.expectShort)(value);
|
||||
};
|
||||
exports.strictParseShort = strictParseShort;
|
||||
const strictParseByte = (value) => {
|
||||
if (typeof value === "string") {
|
||||
return (0, exports.expectByte)(parseNumber(value));
|
||||
}
|
||||
return (0, exports.expectByte)(value);
|
||||
};
|
||||
exports.strictParseByte = strictParseByte;
|
||||
const stackTraceWarning = (message) => {
|
||||
return String(new TypeError(message).stack || message)
|
||||
.split("\n")
|
||||
.slice(0, 5)
|
||||
.filter((s) => !s.includes("stackTraceWarning"))
|
||||
.join("\n");
|
||||
};
|
||||
exports.logger = {
|
||||
warn: console.warn,
|
||||
};
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.resolvedPath = void 0;
|
||||
const extended_encode_uri_component_1 = require("./extended-encode-uri-component");
|
||||
const resolvedPath = (resolvedPath, input, memberName, labelValueProvider, uriLabel, isGreedyLabel) => {
|
||||
if (input != null && input[memberName] !== undefined) {
|
||||
const labelValue = labelValueProvider();
|
||||
if (labelValue.length <= 0) {
|
||||
throw new Error("Empty value provided for input HTTP label: " + memberName + ".");
|
||||
}
|
||||
resolvedPath = resolvedPath.replace(uriLabel, isGreedyLabel
|
||||
? labelValue
|
||||
.split("/")
|
||||
.map((segment) => (0, extended_encode_uri_component_1.extendedEncodeURIComponent)(segment))
|
||||
.join("/")
|
||||
: (0, extended_encode_uri_component_1.extendedEncodeURIComponent)(labelValue));
|
||||
}
|
||||
else {
|
||||
throw new Error("No value provided for input HTTP label: " + memberName + ".");
|
||||
}
|
||||
return resolvedPath;
|
||||
};
|
||||
exports.resolvedPath = resolvedPath;
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.serializeFloat = void 0;
|
||||
const serializeFloat = (value) => {
|
||||
if (value !== value) {
|
||||
return "NaN";
|
||||
}
|
||||
switch (value) {
|
||||
case Infinity:
|
||||
return "Infinity";
|
||||
case -Infinity:
|
||||
return "-Infinity";
|
||||
default:
|
||||
return value;
|
||||
}
|
||||
};
|
||||
exports.serializeFloat = serializeFloat;
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports._json = void 0;
|
||||
const _json = (obj) => {
|
||||
if (obj == null) {
|
||||
return {};
|
||||
}
|
||||
if (Array.isArray(obj)) {
|
||||
return obj.filter((_) => _ != null);
|
||||
}
|
||||
if (typeof obj === "object") {
|
||||
const target = {};
|
||||
for (const key of Object.keys(obj)) {
|
||||
if (obj[key] == null) {
|
||||
continue;
|
||||
}
|
||||
target[key] = (0, exports._json)(obj[key]);
|
||||
}
|
||||
return target;
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
exports._json = _json;
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.splitEvery = void 0;
|
||||
function splitEvery(value, delimiter, numDelimiters) {
|
||||
if (numDelimiters <= 0 || !Number.isInteger(numDelimiters)) {
|
||||
throw new Error("Invalid number of delimiters (" + numDelimiters + ") for splitEvery.");
|
||||
}
|
||||
const segments = value.split(delimiter);
|
||||
if (numDelimiters === 1) {
|
||||
return segments;
|
||||
}
|
||||
const compoundSegments = [];
|
||||
let currentSegment = "";
|
||||
for (let i = 0; i < segments.length; i++) {
|
||||
if (currentSegment === "") {
|
||||
currentSegment = segments[i];
|
||||
}
|
||||
else {
|
||||
currentSegment += delimiter + segments[i];
|
||||
}
|
||||
if ((i + 1) % numDelimiters === 0) {
|
||||
compoundSegments.push(currentSegment);
|
||||
currentSegment = "";
|
||||
}
|
||||
}
|
||||
if (currentSegment !== "") {
|
||||
compoundSegments.push(currentSegment);
|
||||
}
|
||||
return compoundSegments;
|
||||
}
|
||||
exports.splitEvery = splitEvery;
|
||||
Reference in New Issue
Block a user