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

request-is-better

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

request-is-better - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

.github/workflows/npm-publish.yml

2

lib/cjs/index.js

@@ -56,3 +56,3 @@ "use strict";

return {
request,
request: request,
onReceive: onReceive

@@ -59,0 +59,0 @@ };

@@ -6,6 +6,7 @@ export interface MessageToReqResInput {

}
export declare function messagingToRequestResponse(opts: MessageToReqResInput): {
request: (m: unknown) => Promise<unknown> | unknown;
export declare type RequestFunc<TReq = unknown, TRes = unknown> = (m: TReq) => Promise<TRes> | TRes;
export declare function messagingToRequestResponse<TReq = unknown, TRes = unknown>(opts: MessageToReqResInput): {
request: RequestFunc<TReq, TRes>;
onReceive: (m: unknown) => void;
};
//# sourceMappingURL=index.d.ts.map

@@ -49,5 +49,5 @@ "use strict";

}
return { request, onReceive: onReceive };
return { request: request, onReceive: onReceive };
}
exports.messagingToRequestResponse = messagingToRequestResponse;
//# sourceMappingURL=index.js.map

@@ -6,6 +6,7 @@ export interface MessageToReqResInput {

}
export declare function messagingToRequestResponse(opts: MessageToReqResInput): {
request: (m: unknown) => Promise<unknown> | unknown;
export type RequestFunc<TReq = unknown, TRes = unknown> = (m: TReq) => Promise<TRes> | TRes;
export declare function messagingToRequestResponse<TReq = unknown, TRes = unknown>(opts: MessageToReqResInput): {
request: RequestFunc<TReq, TRes>;
onReceive: (m: unknown) => void;
};
//# sourceMappingURL=index.d.ts.map
{
"name": "request-is-better",
"version": "1.0.0",
"version": "1.0.1",
"description": "request-is-better is a TypeScript library which makes it easier to use request-response calls on any channel that implements a send-receive message interface.",

@@ -5,0 +5,0 @@ "isApp": false,

# request-is-better
**Request-is-better** is a TypeScript library which makes it easier to use **request-response** calls on any channel that implements a send-receive message interface.
Like the lib? Support it with a star!

@@ -85,3 +86,5 @@ ## Features

Like the lib? Support it with a star!
# License
The Unlicense

@@ -11,6 +11,8 @@ // PackageName: request-is-better

export function messagingToRequestResponse(opts: MessageToReqResInput) {
export type RequestFunc<TReq = unknown, TRes = unknown> = (m: TReq) => Promise<TRes> | TRes;
export function messagingToRequestResponse<TReq = unknown, TRes = unknown>(opts: MessageToReqResInput) {
let lastRequestId = 0;
const requests: { [key: number]: RequestContext } = {};
function request(m: unknown): Promise<unknown> | unknown {
function request(m: any): Promise<any> | any {
lastRequestId = ++lastRequestId < Number.MAX_SAFE_INTEGER - 1 ? lastRequestId : 1;

@@ -54,3 +56,3 @@ const requestId = lastRequestId;

}
return { request, onReceive: onReceive as (m: unknown) => void };
return { request: request as RequestFunc<TReq, TRes>, onReceive: onReceive as (m: unknown) => void };
}

@@ -57,0 +59,0 @@

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

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