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

@soundify/shared

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@soundify/shared - npm Package Compare versions

Comparing version 0.1.0-alpha.3 to 0.1.1-beta.0

19

esm/mod.js
/**
* Creates URLSearchParams from object
*
* You can use `new URLSearchParams(obj)`, when your object
* extends `Record<string, string>`. Otherwise use this function.
* Creates a query string from the object and skips `undefined`.
*/
export const objectToSearchParams = (obj) => {
export const toQueryString = (obj) => {
const params = new URLSearchParams();
Object.keys(obj).forEach((key) => {
const value = obj[key];
if (typeof value === "undefined")
return;
params.set(key, value.toString());
});
return params;
for (const [name, value] of Object.entries(obj)) {
if (typeof value !== "undefined")
params.set(name, value.toString());
}
return params.toString();
};

@@ -5,8 +5,5 @@ {

"name": "@soundify/shared",
"version": "0.1.0-alpha.3",
"version": "0.1.1-beta.0",
"description": "⚙️ Shared types and functions for soundify packages",
"license": "MIT",
"devDependencies": {
"@types/node": "^18.11.9"
},
"packageManager": "pnpm@7.30.0",

@@ -13,0 +10,0 @@ "repository": {

@@ -1,43 +0,10 @@

export type SearchParam = string | number | boolean | undefined | string[];
export type SearchParams = Record<string, SearchParam>;
/**
* Creates URLSearchParams from object
*
* You can use `new URLSearchParams(obj)`, when your object
* extends `Record<string, string>`. Otherwise use this function.
*/
export declare const objectToSearchParams: <T extends SearchParams>(obj: T) => URLSearchParams;
export type JSONValue = null | string | number | boolean | JSONObject | JSONArray;
export type JSONArray = JSONValue[];
export interface JSONObject {
[x: string]: JSONValue | undefined;
}
export type NonNullableJSON<T extends JSONObject> = {
[K in keyof T]: NonNullable<T[K]>;
export type SearchParam = string | number | boolean | SearchParamArray;
export type SearchParamArray = SearchParam[];
export type SearchParams = {
[k: string]: SearchParam | undefined;
};
export type HTTPMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
export interface FetchOpts {
method?: HTTPMethod;
body?: JSONValue;
query?: SearchParams;
headers?: HeadersInit;
}
export type ExpectedResponse = "json" | "void";
/**
* Interface that provides a fetch method to make HTTP requests.
* Creates a query string from the object and skips `undefined`.
*/
export interface HTTPClient {
/**
* Sends an HTTP request.
*
* @param baseURL
* The base URL for the API request. Must begin with "/"
* @param returnType
* The expected return type of the API response.
* @param opts
* Optional request options, such as the request body or query parameters.
*/
fetch(baseURL: string, responseType: "void", opts?: FetchOpts): Promise<void>;
fetch<R extends JSONValue = JSONValue>(baseURL: string, responseType: "json", opts?: FetchOpts): Promise<R>;
}
export declare const toQueryString: <T extends SearchParams>(obj: T) => string;
/**

@@ -47,9 +14,4 @@ * The interface used to provide access token with the ability to refresh it

export interface IAuthProvider {
/**
* Function that gives you access token.
*
* @param forceRefresh Does the service have to refresh the token, or give you a cached token
* @default false
*/
getAccessToken: (forceRefresh?: boolean) => Promise<string>;
refreshToken(): Promise<string>;
getToken(): string;
}
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