Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

appolo-utils

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

appolo-utils - npm Package Compare versions

Comparing version 0.0.54 to 0.0.55

10

lib/errors.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = require("../index");
class Errors {

@@ -13,4 +14,13 @@ static stack() {

}
static errorToString(err) {
let output = "";
if (!err) {
return output;
}
return (err instanceof Error)
? err.stack || err.toString()
: index_1.Objects.tryStringifyJSON(err);
}
}
exports.Errors = Errors;
//# sourceMappingURL=errors.js.map
import CallSite = NodeJS.CallSite;
import {Objects} from "../index";

@@ -17,3 +18,16 @@ export class Errors {

public static errorToString(err: Error): string {
let output = "";
if (!err) {
return output
}
return (err instanceof Error)
? err.stack || err.toString()
: Objects.tryStringifyJSON(err)
}
}

14

lib/objects.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const arrays_1 = require("./arrays");
const index_1 = require("../index");
class Objects {

@@ -75,10 +76,9 @@ static isPlain(obj) {

static tryParseJSON(jsonString) {
try {
let o = JSON.parse(jsonString);
return o;
}
catch (e) {
}
return null;
let [err, output] = index_1.Functions.to(() => JSON.parse(jsonString));
return err ? null : output;
}
static tryStringifyJSON(json) {
let [err, str] = index_1.Functions.to(() => JSON.stringify(json));
return err ? "" : str;
}
static pick(obj, ...pick) {

@@ -85,0 +85,0 @@ let out = {};

import {Arrays} from "./arrays";
import {Functions} from "../index";

@@ -103,11 +104,13 @@ export class Objects {

public static tryParseJSON(jsonString: string): any {
try {
let o = JSON.parse(jsonString);
let [err, output] = Functions.to(() => JSON.parse(jsonString));
return o;
} catch (e) {
}
return err ? null : output;
}
return null;
public static tryStringifyJSON(json: any): string {
let [err, str] = Functions.to(() => JSON.stringify(json))
return err ? "" : str;
}

@@ -120,3 +123,3 @@

let key = pick[i];
if(key in obj){
if (key in obj) {
out[key] = obj[key];

@@ -123,0 +126,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = require("../index");
class Strings {

@@ -29,8 +30,4 @@ static stringifyObjectValues(obj) {

static tryDecodeURIComponent(str) {
try {
return decodeURIComponent(str || "");
}
catch (e) {
return str || "";
}
let [err, output] = index_1.Functions.to(() => decodeURIComponent(str || ""));
return err ? str || "" : output;
}

@@ -37,0 +34,0 @@ }

@@ -0,1 +1,3 @@

import {Functions} from "../index";
export class Strings {

@@ -34,8 +36,7 @@ public static stringifyObjectValues(obj: { [index: string]: string | boolean | number }): string {

public static tryDecodeURIComponent(str): string {
try {
return decodeURIComponent(str || "");
} catch (e) {
return str || ""
}
let [err, output] = Functions.to(() => decodeURIComponent(str || ""));
return err ? str || "" : output;
}
}

@@ -17,3 +17,3 @@ {

"main": "./index.js",
"version": "0.0.54",
"version": "0.0.55",
"license": "MIT",

@@ -20,0 +20,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc