@servita/utilities
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -1,17 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = void 0; | ||
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
/* eslint-disable no-console, node/no-process-env */ | ||
var _default = function _default(variableArray) { | ||
var envArr = {}; | ||
export default (variableArray => { | ||
const envArr = {}; | ||
@@ -22,21 +9,10 @@ if (!Array.isArray(variableArray)) { | ||
var missingVariables = []; | ||
const missingVariables = []; | ||
var _iterator = _createForOfIteratorHelper(variableArray), | ||
_step; | ||
for (const variable of variableArray) { | ||
if (!process.env[variable]) { | ||
missingVariables.push(variable); | ||
} | ||
try { | ||
for (_iterator.s(); !(_step = _iterator.n()).done;) { | ||
var variable = _step.value; | ||
if (!process.env[variable]) { | ||
missingVariables.push(variable); | ||
} | ||
envArr[variable] = process.env[variable]; | ||
} | ||
} catch (err) { | ||
_iterator.e(err); | ||
} finally { | ||
_iterator.f(); | ||
envArr[variable] = process.env[variable]; | ||
} | ||
@@ -48,6 +24,3 @@ | ||
} | ||
return envArr; | ||
}; | ||
exports["default"] = _default; | ||
}); |
@@ -1,23 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "envCheck", { | ||
enumerable: true, | ||
get: function get() { | ||
return _envCheck["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "otelToDatadog", { | ||
enumerable: true, | ||
get: function get() { | ||
return _otelToDatadog["default"]; | ||
} | ||
}); | ||
var _envCheck = _interopRequireDefault(require("./env-check")); | ||
var _otelToDatadog = _interopRequireDefault(require("./otel-to-datadog")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
export { default as envCheck } from './env-check'; | ||
export { default as otelToDatadog } from './otel-to-datadog'; |
@@ -1,30 +0,3 @@ | ||
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _exportNames = {}; | ||
exports["default"] = void 0; | ||
var servitaUtilities = _interopRequireWildcard(require("./exports")); | ||
Object.keys(servitaUtilities).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
if (key in exports && exports[key] === servitaUtilities[key]) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return servitaUtilities[key]; | ||
} | ||
}); | ||
}); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
var _default = servitaUtilities; | ||
exports["default"] = _default; | ||
import * as servitaUtilities from "./exports"; | ||
export * from './exports'; | ||
export default servitaUtilities; |
@@ -1,20 +0,13 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = _default; | ||
// Taken from https://docs.datadoghq.com/tracing/connect_logs_and_traces/opentelemetry/ | ||
/* eslint-disable no-param-reassign */ | ||
/* eslint-disable no-bitwise */ | ||
var UINT_MAX = 4294967296; // Read a buffer to unsigned integer bytes. | ||
const UINT_MAX = 4294967296; | ||
var readInt32 = function readInt32(buffer, offset) { | ||
// Read a buffer to unsigned integer bytes. | ||
const readInt32 = function (buffer, offset) { | ||
return buffer[offset + 0] * 16777216 + (buffer[offset + 1] << 16) + (buffer[offset + 2] << 8) + buffer[offset + 3]; | ||
}; // Write unsigned integer bytes to a buffer. | ||
}; | ||
var writeUInt32BE = function writeUInt32BE(buffer, value, offset) { | ||
// Write unsigned integer bytes to a buffer. | ||
const writeUInt32BE = function (buffer, value, offset) { | ||
buffer[3 + offset] = value & 255; | ||
@@ -27,16 +20,20 @@ value = value >> 8; | ||
buffer[0 + offset] = value & 255; | ||
}; // Convert a buffer to a numerical string. | ||
}; | ||
// Convert a buffer to a numerical string. | ||
const toNumberString = function (buffer, radix) { | ||
let high = readInt32(buffer, 0); | ||
let low = readInt32(buffer, 4); | ||
let str = ''; | ||
var toNumberString = function toNumberString(buffer, radix) { | ||
var high = readInt32(buffer, 0); | ||
var low = readInt32(buffer, 4); | ||
var str = ''; | ||
radix = radix || 10; // eslint-disable-next-line no-constant-condition | ||
radix = radix || 10; | ||
// eslint-disable-next-line no-constant-condition | ||
while (1) { | ||
var mod = high % radix * UINT_MAX + low; | ||
const mod = high % radix * UINT_MAX + low; | ||
high = Math.floor(high / radix); | ||
low = Math.floor(mod / radix); | ||
str = (mod % radix).toString(radix) + str; | ||
if (!high && !low) break; | ||
@@ -46,16 +43,20 @@ } | ||
return str; | ||
}; // Convert a numerical string to a buffer using the specified radix. | ||
}; | ||
// Convert a numerical string to a buffer using the specified radix. | ||
const fromString = function (str, raddix) { | ||
const buffer = new Uint8Array(8); | ||
const len = str.length; | ||
var fromString = function fromString(str, raddix) { | ||
var buffer = new Uint8Array(8); | ||
var len = str.length; | ||
var pos = 0; | ||
var high = 0; | ||
var low = 0; | ||
let pos = 0; | ||
let high = 0; | ||
let low = 0; | ||
if (str[0] === '-') pos++; | ||
var sign = pos; | ||
const sign = pos; | ||
while (pos < len) { | ||
var chr = parseInt(str[pos++], raddix); | ||
const chr = parseInt(str[pos++], raddix); | ||
if (!(chr >= 0)) break; // NaN | ||
@@ -80,13 +81,16 @@ | ||
writeUInt32BE(buffer, low, 4); | ||
return buffer; | ||
}; | ||
function _default(traceId, spanId) { | ||
var traceIdEnd = traceId.slice(traceId.length / 2); | ||
var convertedTraceId = toNumberString(fromString(traceIdEnd, 16)); | ||
var convertedSpanId = toNumberString(fromString(spanId, 16)); | ||
return { | ||
convertedTraceId: convertedTraceId, | ||
convertedSpanId: convertedSpanId | ||
}; | ||
export default function (traceId, spanId) { | ||
if (traceId && spanId) { | ||
const traceIdEnd = traceId.slice(traceId.length / 2); | ||
const convertedTraceId = toNumberString(fromString(traceIdEnd, 16)); | ||
const convertedSpanId = toNumberString(fromString(spanId, 16)); | ||
return [convertedTraceId, convertedSpanId]; | ||
} | ||
return []; | ||
} |
{ | ||
"name": "@servita/utilities", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "A set of useful utilities", | ||
@@ -17,2 +17,3 @@ "main": "dist/index.js", | ||
"@nikic/eslint-config": "^2.0.2", | ||
"babel-cli": "^6.26.0", | ||
"eslint": "^8.12.0", | ||
@@ -19,0 +20,0 @@ "eslint-plugin-node": "^11.1.0" |
@@ -27,3 +27,3 @@ ## Set of Servita utiliy functions | ||
```javascript | ||
const {convertedTraceId, convertedSpanId} = otelToDatadog(traceId, spanId); | ||
const [convertedTraceId, convertedSpanId] = otelToDatadog(traceId, spanId); | ||
``` |
@@ -87,2 +87,3 @@ // Taken from https://docs.datadoghq.com/tracing/connect_logs_and_traces/opentelemetry/ | ||
export default function (traceId, spanId) { | ||
if (traceId && spanId) { | ||
const traceIdEnd = traceId.slice(traceId.length / 2); | ||
@@ -92,3 +93,6 @@ const convertedTraceId = toNumberString(fromString(traceIdEnd, 16)); | ||
return {convertedTraceId, convertedSpanId}; | ||
return [convertedTraceId, convertedSpanId]; | ||
} | ||
return []; | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
7637
8
197