New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ts-commons

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-commons - npm Package Compare versions

Comparing version 0.0.15 to 0.0.16

9

dist/utils/object.utils.d.ts

@@ -11,2 +11,11 @@ export declare class ObjectUtils {

static toSafeString(value: any): string;
static getProperty<T, K extends keyof T>(obj: T, key: K): T[K];
static setProperty<T, K extends keyof T>(obj: T, key: K, value: T[K]): void;
static getClassName<T>(o: T | {
new (): T;
}): string;
static createObject<T>(type: {
new (): T;
}): T;
static getPropertyName<T>(fn: (o: T) => any): string;
}

@@ -40,2 +40,37 @@ "use strict";

};
ObjectUtils.getProperty = function (obj, key) {
return obj[key]; // Inferred type is T[K]
};
ObjectUtils.setProperty = function (obj, key, value) {
obj[key] = value;
};
ObjectUtils.getClassName = function (o) {
if (this.isNullOrUndefined(o)) {
return "";
}
var testObj = typeof o === "function" ? new o() : o;
return testObj.constructor.name;
};
ObjectUtils.createObject = function (type) {
if (this.isNullOrUndefined(type)) {
return null;
}
return new type();
};
// getPropertyName<Student>((student) => student.name) return name
// getPropertyName<Student>((student) => student.age) return age
ObjectUtils.getPropertyName = function (fn) {
if (this.isNullOrUndefined(fn)) {
return "";
}
// ES5: function (name) { return student.name; }
// ES6: (student) => student.name;
var expression = fn.toString();
var returnIndex = expression.indexOf("return");
var regexp = returnIndex > -1
? new RegExp("^.*return\\s+\\w+.(\\w+)\\s*;\\s*\\}\\s*$")
: RegExp("^\\s*\\(?\\w+\\)?\\s*=>\\s*\\w+\\.(\\w+)\\s*$");
var match = regexp.exec(expression);
return !this.isNullOrUndefined(match) && match.length === 2 ? match[1] : "";
};
return ObjectUtils;

@@ -42,0 +77,0 @@ }());

2

package.json
{
"name": "ts-commons",
"version": "0.0.15",
"version": "0.0.16",
"description": "common methods for typescript",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

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