@vercel/stega
Advanced tools
Comparing version 0.0.4 to 0.0.5
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.vercelStegaEncode = void 0; | ||
exports.vercelStegaCombine = exports.vercelStegaEncode = void 0; | ||
const map_1 = require("./map"); | ||
@@ -25,1 +25,27 @@ /** | ||
exports.vercelStegaEncode = vercelStegaEncode; | ||
function isDate(string) { | ||
return Boolean(Date.parse(string)); | ||
} | ||
function isUrl(string) { | ||
try { | ||
new URL(string); | ||
} | ||
catch { | ||
return false; | ||
} | ||
return true; | ||
} | ||
/** | ||
* Adds an encoded JSON object to a string as hidden characters | ||
* @param string - The string the JSON will be added to | ||
* @param json - The JSON to add to the string | ||
* @param skip - Whether to skip encoding (default: "auto") | ||
*/ | ||
function vercelStegaCombine(string, json, skip = 'auto') { | ||
if (skip === true) | ||
return string; | ||
if (skip === 'auto' && (isDate(string) || isUrl(string))) | ||
return string; | ||
return `${string}${vercelStegaEncode(json)}`; | ||
} | ||
exports.vercelStegaCombine = vercelStegaCombine; |
@@ -7,1 +7,10 @@ /** | ||
export declare function vercelStegaEncode<T>(json: T): string; | ||
type SkipValue = 'auto' | boolean; | ||
/** | ||
* Adds an encoded JSON object to a string as hidden characters | ||
* @param string - The string the JSON will be added to | ||
* @param json - The JSON to add to the string | ||
* @param skip - Whether to skip encoding (default: "auto") | ||
*/ | ||
export declare function vercelStegaCombine<T>(string: string, json: T, skip?: SkipValue): string; | ||
export {}; |
@@ -21,1 +21,26 @@ import { HEX_DIGIT_MAP } from './map'; | ||
} | ||
function isDate(string) { | ||
return Boolean(Date.parse(string)); | ||
} | ||
function isUrl(string) { | ||
try { | ||
new URL(string); | ||
} | ||
catch { | ||
return false; | ||
} | ||
return true; | ||
} | ||
/** | ||
* Adds an encoded JSON object to a string as hidden characters | ||
* @param string - The string the JSON will be added to | ||
* @param json - The JSON to add to the string | ||
* @param skip - Whether to skip encoding (default: "auto") | ||
*/ | ||
export function vercelStegaCombine(string, json, skip = 'auto') { | ||
if (skip === true) | ||
return string; | ||
if (skip === 'auto' && (isDate(string) || isUrl(string))) | ||
return string; | ||
return `${string}${vercelStegaEncode(json)}`; | ||
} |
{ | ||
"name": "@vercel/stega", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Utilities for steganography", | ||
@@ -5,0 +5,0 @@ "main": "./dist/cjs/index.js", |
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
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
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
30731
18
376
0
53