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

@corentinth/chisels

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@corentinth/chisels - npm Package Compare versions

Comparing version 1.0.4 to 1.1.0

30

dist/index.d.ts

@@ -144,2 +144,30 @@ /**

export { type DeepPartial, type Dictionary, type Expand, type PartialBy, type Subtract, castError, formatBytes, injectArguments, safely, safelySync };
/**
* Join URL parts and trim slashes.
*
* @example
* ```typescript
* const url = joinUrlPaths('/part1/', '/part2/', 'part3', 'part4/');
*
* console.log(url); // 'part1/part2/part3/part4'
* ```
*/
declare function joinUrlPaths(...parts: string[]): string;
/**
* Functional wrapper around URL constructor to build an URL string from a base URL and optional path, query params and hash.
*
* @example
* ```typescript
* const url = buildUrl({ baseUrl: 'https://example.com', path: 'foo', queryParams: { a: '1', b: '2' }, hash: 'hash' });
*
* console.log(url); // 'https://example.com/foo?a=1&b=2#hash'
* ```
*/
declare function buildUrl({ path, baseUrl, queryParams, hash, }: {
path?: string;
baseUrl: string;
queryParams?: Record<string, string> | URLSearchParams;
hash?: string;
}): string;
export { type DeepPartial, type Dictionary, type Expand, type PartialBy, type Subtract, buildUrl, castError, formatBytes, injectArguments, joinUrlPaths, safely, safelySync };

2

package.json
{
"name": "@corentinth/chisels",
"type": "module",
"version": "1.0.4",
"version": "1.1.0",
"packageManager": "pnpm@9.9.0",

@@ -6,0 +6,0 @@ "description": "Collection of utilities for JavaScript and TypeScript, lightweight and tree-shakable.",

@@ -43,2 +43,36 @@ # Chisels - JS/TS utilities and types

### `safelySync`
Function - [See source](./src/safely.ts#L43)
Safely executes a function and return a tuple with the result and an error if any.
```typescript
const [result, error] = safelySync(myFunction);
if (error) {
console.error(error);
}
console.log(result);
```
### `safely`
Function - [See source](./src/safely.ts#L20)
Safely executes an async function or promise and return a tuple with the result and an error if any.
```typescript
const [result, error] = await safely(myFunction);
if (error) {
console.error(error);
}
console.log(result);
```
### `formatBytes`

@@ -74,34 +108,26 @@

### `safelySync`
### `joinUrlPaths`
Function - [See source](./src/safely.ts#L43)
Function - [See source](./src/url.ts#L13)
Safely executes a function and return a tuple with the result and an error if any.
Join URL parts and trim slashes.
```typescript
const [result, error] = safelySync(myFunction);
const url = joinUrlPaths('/part1/', '/part2/', 'part3', 'part4/');
if (error) {
console.error(error);
}
console.log(result);
console.log(url); // 'part1/part2/part3/part4'
```
### `safely`
### `buildUrl`
Function - [See source](./src/safely.ts#L20)
Function - [See source](./src/url.ts#L27)
Safely executes an async function or promise and return a tuple with the result and an error if any.
Functional wrapper around URL constructor to build an URL string from a base URL and optional path, query params and hash.
```typescript
const [result, error] = await safely(myFunction);
const url = buildUrl({ baseUrl: 'https://example.com', path: 'foo', queryParams: { a: '1', b: '2' }, hash: 'hash' });
if (error) {
console.error(error);
}
console.log(result);
console.log(url); // 'https://example.com/foo?a=1&b=2#hash'
```

@@ -108,0 +134,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

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