open-index/open-npm huggingface dataset:
npm package: @lgse/esbuild-jest
Description: Jest plugin to use esbuild for transformation
Author: Arjay Elbore
Latest version: 1.0.2

# esbuild-jest

### A Jest transformer using esbuild
With this transformer you can use and transform (ts, js, tsx and jsx) files

## Install

```bash
npm install --save-dev @lgse/esbuild-jest esbuild
```

#### Setting up Jest config file

esbuild-jest transformer should be used in your Jest config file like this:

```js
{
  "transform": {
    "^.+\\.tsx?$": "@lgse/esbuild-jest"
  }
}
```

#### Setting up Jest config file with transformOptions
```typescript
export interface Options {
  jsxFactory?: string
  jsxFragment?: string
  sourcemap?: boolean | 'inline' | 'external'
  loaders?: {
    [ext: string]: Loader
  },
  target?: string
  format?: string
  define?: { [key: string]: string }
}
```

```js
{
  "transform": {
    "^.+\\.tsx?$": [ 
      "@lgse/esbuild-jest", 
      { 
        sourcemap: true,
        loaders: {
          '.spec.ts': 'tsx'
        }
      } 
    ]
  }
}
```

> Note: if you are using tsconfig.json and jsconfig.json with "paths", Please look `alias-hq` and there documentation https://github.com/davestewart/alias-hq/blob/master/docs/integrations.md
npm package: @lgse/ts-results
Description: ts-results is a lightweight Javascript library developed to solve a common problem. It returns an object indicating success or failure of an operation instead of throwing/using exceptions.
Author: Pierre Berube
Latest version: 1.4.0

# ts-results

ts-results is a lightweight Javascript library developed to solve a common problem. It returns an object indicating success or failure of an operation instead of throwing/using exceptions. Inspired by [Fluent Results Library for C#](https://github.com/altmann/FluentResults)
# Install
```
npm install @lgse/ts-results
```

# Usage

**Result.ok()**:
```typescript
const result = Result.ok();

// result.isOk() returns true
```

**Result\<T>.ok()**:
```typescript
const result = Result<Array<number>>.ok([1, 2, 3]);
const data = result.data(); // [1,2,3]

// result.IsOk() returns true
```

**Result.ok().withData()**:
```typescript
const result = Result.ok().withData([1, 2, 3]);
```

**Result.ok\<T>()**:
```typescript
const typedResult = Result.ok<Array<number>>();

typedResult.withData(['Joe', 'Bill']); // Wrong type, will throw error
typedResult.withData([1, 2, 3]) // OK
```

**Result.fail()**:
```typescript
const result = Result.fail();

// With Error
const result2 = Result.fail(new Error('Failed because X'));
```

**Result.failIf()**:
```typescript
const result = Result.failIf(1 + 1 === 2); // Fails with truthy condition

// With Error
const result2 = Result.failIf(1 + 1 === 2, new Error('Failed because X'));
```

**Result.try()**:
```typescript
const result = Result.try(() => {
  throw new Error('An error occurred');
}); // Will fail

// With Optional Error Transformer
const result2 = Result.try(() => {
  throw new Error('An error occurred');
}, (e: Error) => new CustomError('...'));
```

**Result.hasErrors()**:
```typescript
  const error = new Error();
  const result = Result.fail(error);
  
  result.hasError(); // true
```

**Result.hasErrorType()**:
```typescript
  class CustomError extends Error {}

  const error = new CustomError();
  const result = Result.fail(error);

  result.hasErrorType(CustomError); // true
```
npm package: @lgse/use-axios-query
Description: use-axios-query is a wrapper around axios and react-query.
Author: Pierre Berube
Latest version: 1.6.0

# useAxiosQuery
useAxiosQuery is a wrapper around the [axios](https://github.com/axios/axios) HTTP Client, [axios-retry](https://github.com/softonic/axios-retry) and [@tanstack/react-query](https://github.com/TanStack/query)

- Automatically retries idempotent requests
- Automatically cancels outgoing http requests if the calling component of the `useAxiosQuery` hook unmounts
- Customizable 401 Status Code Handler
- Highly configurable

# Install
The following peer dependencies are required:
- [axios](https://www.npmjs.com/package/axios) `1.x.x`
- [axios-retry](https://www.npmjs.com/package/axios-retry) `3.x.x`
- [@tanstack/react-query](https://www.npmjs.com/package/@tanstack/react-query) `4.x.x`
- [react](https://www.npmjs.com/package/react) `17.x.x` or `18.x.x`

```
npm install --save @lgse/use-axios-query axios axios-retry @tanstack/react-query
```

# Usage

```typescript jsx
import * as React from 'react';
import { useAxiosQuery } from './useAxiosQuery';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'

type Todo = {
  completed: boolean;
  id: number;
  todo: string;
}

type DataType = Todo[]

type ResponseType = {
  todos: Todo[]
}

const Todos = () => {
  const [data, { error }] = useAxiosQuery<DataType>(['todos'], (axios, cancelRequest) => {
    return axios.get<ResponseType>('https://dummyjson.com/todos').then(({ data: { todos } }) => todos);
  });

  if (Array.isArray(data) && !data.length) {
    return <div>No todos to show</div>
  }

  if (Array.isArray(data) && data.length) {
    return data.map(({ completed, id, todo }) => <div key={id}>{todo}{completed ? ' - Done!' : ''}</div>;
  }

  if (error) {
    return <div>Error fetching todos :(</div>;
  }

  return <div>Loading...</div>
};

const App = () => {
  return (
    <QueryClientProvider client={new QueryClient()}>
      <Todos />
    </QueryClientProvider>
  )
}
```