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

useful-object

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

useful-object - npm Package Compare versions

Comparing version 0.1.3 to 0.2.0

4

dist/index.d.ts

@@ -5,5 +5,9 @@ import { Observable } from "rxjs";

get(path: string, def?: any): any;
getSafe<T, R>(fn: (obj: T) => R, def?: R): any;
toObservable(): Observable<any>;
toPromise(): Promise<any>;
}
interface Promise<T> {
delay(ms: number): Promise<T>;
}
}

@@ -8,2 +8,10 @@ "use strict";

};
Object.prototype.getSafe = function take(fn, def) {
var returnValue = def;
try {
returnValue = fn(this);
}
catch (error) { }
return returnValue;
};
Object.prototype.toObservable = function () {

@@ -16,1 +24,5 @@ return rxjs_1.of(this);

};
Promise.prototype.delay = function (ms) {
var _this = this;
return new Promise(function (resolve) { return setTimeout(function () { return resolve(_this); }, ms); });
};

2

package.json
{
"name": "useful-object",
"version": "0.1.3",
"version": "0.2.0",
"description": "Typescript util to add useful methods to global Object type.",

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

@@ -13,3 +13,3 @@ # Useful Object

```sh
```typescript
import "useful-object"; // 16 KB

@@ -29,2 +29,23 @@

## Need type safety?
```typescript
interface MyInterface {
name: {
firstName: string;
lastName: string;
};
}
const obj: MyInterface = {
name: {
firstName: "Avi",
lastName: "Punes"
}
};
const firstName: string = obj.getSafe<MyInterface, string>(obj => obj.name.firstName); // Avi
const lastName: string = obj.getSafe((obj: MyInterface) => obj.name.lastName); // Punes
```
## Test

@@ -31,0 +52,0 @@

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