UNPKG

bc-payments-sdk

Version:

BetterCommerce's Payments NodeJS SDK is a complete solution for storefront clients that integrate payments. `bc-payments-sdk` is a single point interface for storefront clients for interacting with payment gateways.

38 lines (37 loc) 995 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Guid = void 0; class Guid { static newGuid() { return new Guid('xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => { const r = Math.random() * 16 | 0; const v = (c == 'x') ? r : (r & 0x3 | 0x8); return v.toString(16); })); } static get empty() { return '00000000-0000-0000-0000-000000000000'; } get empty() { return Guid.empty; } static isValid(str) { const validRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i; return validRegex.test(str); } constructor(value) { this.value = this.empty; if (value) { if (Guid.isValid(value)) { this.value = value; } } } toString() { return this.value; } toJSON() { return this.value; } } exports.Guid = Guid;