open-index/open-npm huggingface dataset:
npm package: @stayradiated/error-boundary
Description: Catch and return errors as values
Author: George Czabania
Latest version: 4.3.0

# @stayradiated/error-boundary

Stop throwing errors, try passing them as values instead.

An Error Boundary guarantees to return any caught exceptions to make it easier
to reason about your code.

Shout out to @brendonjohn for introducing me to this function.

## Installation

```shell
npm install --save @stayradiated/error-boundary
```

## API

- `errorBoundary<T>(fn: () => Promise<T|Error>): Promise<T|Error>`
- `errorBoundarySync<T>(fn: () => T|Error): T|Error`
- `errorListBoundary<T>(fn: () => Promise<Array<T|Error>>): Promise<T[]|Error>`
- `errorListBoundarySync<T>(fn: () => Array<T|Error>): T[]|Error`
- `assertOk<T>(value: T | Error): asserts value is T extends Error ? never : T`
- `assertError<T>(value: T | Error, errorMessage?: string): asserts value is Error`

## Usage

```javascript
const { errorBoundarySync } = await import('@stayradiated/error-boundary')

const mayThrow = () => {
  if (Math.random() > 0.5) {
    throw new Error('Woah, something broke!')
  } else {
    return 'All good here!'
  }
}

const valueOrError = errorBoundarySync(() => mayThrow())

if (valueOrError instanceof Error) {
  // explicititly handle error
  console.error(valueOrError)
} else{
  // handle result
  console.log(valueOrError)
}
```

```javascript
const { errorListBoundary } = await import('@stayradiated/error-boundary')

const results = await errorListBoundary(Promise.all(
  jobs.map(async (item) => {
    return runJob(item)
  })
))
if (results instanceof Error) {
  const error = results
  logError(error)
  return
}
```

## MIT License

Copyright © 2021 George Czabania

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the “Software”), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
npm package: @stayradiated/gatsby-remark-video
Description: Embed video tags in your gatsby project
Author: George Czabania
Latest version: 2.4.0

## @stayradiated/gatsby-remark-video

> Embeds video tag in your gatsby project

This is a fork of
[`nullhook/gatsby-remark-video`](https://github.com/nullhook/gatsby-remark-video).

**Key differences:**

- You can override the default options (width, height, etc) for each video you
  embed.
- You can set any attribute on the video tag
- The video tag is wrapped in a parent div to make it easier to style

**Other differences:**

- Options are parsed using TOML
- Type checking with typescript
- Unit tests

## Installation

```bash
npm install @stayradiated/gatsby-remark-video
```
 
Add the following in your `gatsby-config.js`

```javascript
{
  resolve: '@stayradiated/gatsby-remark-video',
  options: {
    parentTag: 'div',
    parentClass: 'gatsby-remark-video',
    defaultAttributes: {}
  }
}
```

## Usage

In your markdown add the `video({ ... })` tag.

Options are parsed as a [TOML Inline
Table](https://github.com/toml-lang/toml#user-content-inline-table).

```markdown
`video({ src = "./my_video.mp4" })`
```

You can also add a title to the video tag by adding it in your markdown

```markdown
`video({ title = "Short demo", src = "./my_video.mp4" })`
```

All `<video />` tag attributes are supported, and can even be placed on
multiple lines.

```markdown
`video({
  title = "Short demo",
  src = "./my_video.mp4",
  width = 500,
  height = "auto",
  autoplay = true
})`
```

Both single quotes and double quotes are supported.

```markdown
`video({ title = 'Short "demo"', src = './my_video.mp4' })`
```

You can even escape quotes with backslashes.

```markdown
`video({ title = "Short \"demo\"", src = './my_video.mp4' })`
```

## Plugin Options

### Default Attributes

You can set default attributes for all video tags in `gatsby-config.js`.

```javascript
{
  resolve: '@stayradiated/gatsby-remark-video',
  options: {
    defaultAttributes: {
      width: 800,
      height: 'auto',
      preload: 'auto',
      muted: true,
      autoplay: true,
      playsinline: true,
      controls: false,
      loop: true
    }
  }
}
```

### Parent Element

By default, all video tags are wrapped in a `<div class="gatsby-remark-video">`
tag. You can customise the tag type and class name.

```javascript
{
  resolve: '@stayradiated/gatsby-remark-video',
  options: {
    parentTag: 'p',
    parentClass: 'video'
  }
}
```
npm package: @stayradiated/jsconfig
Description: My personal config files for Javascript projects.
Author: George Czabania
Latest version: 2.3.0

# @stayradiated/jsconfig

## How do I use this?

You don't. These are my personal config files and can change at any time.

If you like the idea, fork the repo -- this way you can customise the config to
suit your tastes and aren't going to be surprised if I suddenly decide to bring
back semicolons.

## How do you use this?

This is the typically one of the first commands I run after starting a new JS
project.

```
npx @stayradiated/jsconfig
```

This will modify the nearest `package.json` and add the following scripts:

- `tidy`: lint your code with `xo --fix`
- `test`: test your code with `vitest`
- `build`: build your code with `tsc`

## Implementation

This package relies on `read-pkg-up` and `write-pkg` to do the heavy lifting.
These dependencies are used to modify the nearest `package.json` file:

- several dependencies are injected into the `.devDependencies`, so that you
  can run `xo` and `vitest` locally within your project. The versions of these
  dependencies are set by `jsconfig` and may not be the latest available
  versions.
- several scripts are injected into the `.scripts`, so that you can run `tidy`,
  `test` and `build`
- several config definitions are overwritten, including `.xo`, and `.prettier`.
  It overwrites instead of extending so that old properties can be removed in
  the future.

Typescript doesn't support reading configuration from `package.json` so instead
we have to write to `tsconfig.json`. This file is also overwritten each time,
so any local modifications will be removed.
npm package: @stayradiated/pkg
Description: Utils for creating, building and testing NPM packages
Author: George Czabania
Latest version: 5.8.0

![PKG](./PKG.png)

> My scripts for writing typescript code.

## Installation

```
npm install --save-dev @stayradiated/pkg
```

## Recommended Scripts

Copy the following into your `package.json`.

```json
"scripts": {
  "build": "pkg-build",
  "lint": "pkg-lint",
  "tidy": "pkg-tidy",
  "test": "pkg-test",
  "precommit": "pkg-precommit"
}
```

### Type declarations

If you need to use a 3rd party library that doesn't have typescript support,
you can provide your own type declarations.

There are some strict rules you need to follow for this to work:

1. You must only mock one dependency per file.
1. You must place the file inside the `./src/types/` folder.
2. The filename must be the same as the dependency name.
3. The extension must be `.d.ts`.

For example, if you are providing types for `file-exists`, the types must be
saved in `./src/types/file-exists.d.ts.`

### Providing Typescript types for a project written in JS

If you are manually adding types for a non-typescript project, you must keep
your types in the root of your project, in a file named `types.d.ts`.

`@stayradiated/package` will not use the typescript compiler if your package.json
contains the value: `"types": "types.d.ts"`.

## Lifecycle Test Helpers

AVA does not support "before all" or "after all" functions, because it runs
everything in parallel.

Package has got your back though. If you need to setup/teardown a database,
then this is for you.

Please note, that if you run AVA in watch mode, the "after all" function will
not be called until you exit AVA.

### Before All

Create a file called `testHelpers/beforeAll.js` in the root of your project,
and it will be executed before the tests begin.

### After All

Create a file called `testHelpers/afterAll.js` in the root of your project,
and it will be executed after the tests finish.

It will be called regardless of whether the tests passed or failed.

## Different Folder Structure

### srcPath

If your code is kept in a folder that isn't `src` then you can change the path
by adding the following to your `package.json`

```
"srcPath": "lib",
```

### distPath

Would you like your compiled code to be in a folder that isn't named `dist`?

```
"distPath": "public"
```

### testsPath

Tests must be defined inside the `srcPath`, and by default match any files that
end in `.spec.js`.

```
"testsPath": "**/*.test.js",
```
npm package: @stayradiated/react-floating-label
Description: A material design styled floating label input using react.js
Author: Gokulakrishnan Kalaikovan
Latest version: 1.0.5

# @stayradiated/react-floating-label
> Floating label input.

Checkout the [DEMO](http://code-kotis.github.io/react-floating-label/)

__Install it:__

```sh
npm install --save @stayradiated/react-floating-label
```

__Usage:__

```js
var FloatingLabel = require('@stayradiated/react-floating-label');

<FloatingLabel
	errorMsg='Full name can contain only the alphabets and space'
	pattern={/^[a-z\s]+$/i}/>

```

__Props:__


```js
autoComplete: PropTypes.bool,
errorMsg: PropTypes.string,
placeholder: PropTypes.string.isRequired,
pattern: PropTypes.any,
type: PropTypes.string.isRequired,
id: PropTypes.string.isRequired,
isDisabled: PropTypes.bool
```

__License:__

MIT
npm package: @stayradiated/slog
Description: Log a message with a promise, including a success or fail message
Author: George Czabania
Latest version: 1.4.0

# Slog

> Track how long an async task is taking

## Installation

```
npm install @stayradiated/slog
```

## Usage

```javascript
import slog from '@stayradiated/slog'
import execa from 'execa'

await slog(
  'Installing dependencies',
  execa('npm', ['install'])
)

/*
Installing dependencies (0:00)
Installing dependencies (0:01)
Installing dependencies (0:02)
Installing dependencies (0:03) ✓
*/
```
npm package: @stayradiated/toragent
Description: Easily create and manage Tor requests
Latest version: 2.2.0

# toragent

Easily manage HTTP(S) requests through Tor. TorAgent spawns Tor processes,
handles both HTTP and HTTPS requests, and offers easy IP address rotation.
Compatible with `http.request` and libraries like `request`.

[![Build Status](https://travis-ci.org/danielstjules/toragent.svg?branch=master)](https://travis-ci.org/danielstjules/toragent)

## Installation

Requires Node >= 4.

```
npm install --save @stayradiated/toragent
```

## Overview

Works with promises.

```typescript
import { TorHttpsAgent } from '@stayradiated/toragent'
import got from 'got'

const agent = await TorHttpsAgent.create()

const response = await got({
  url: 'https://www.google.com',
  agent
})
```

## TorAgent

An HTTP Agent for proxying requests through Tor using SOCKS5. In the following
examples, `agent` refers to an instance of `TorAgent`.

#### TorAgent.create(verbose, [fn])

Spawns a Tor process listening on a random unused port, and creates an
agent for use with HTTP(S) requests. The optional verbose param will enable
console output while initializing Tor. Accepts an optional callback,
otherwise it returns a promise that resolves with an instance of TorAgent.
Note that since the Tor process is using a new DataDirectory with no cached
microdescriptors or any other state, bootstrapping can take between 15 - 60s.
The resulting child process is automatically killed when node exits.

``` javascript
TorAgent.create(true).then((agent) => {
  // Spawning Tor
  // Tor spawned with pid 42776 listening on 55683
});
```

#### agent.rotateAddress()

Rotates the IP address used by Tor by sending a SIGHUP. Returns a promise
that resolves when complete.

``` javascript
TorAgent.create().then(agent => agent.rotateAddress());
```

#### agent.destroy()

Closes all sockets handled by the agent, and closes the Tor process. Returns
a promise that resolves when the Tor process has closed.

``` javascript
TorAgent.create().then(agent => agent.destroy());
```
npm package: @stayradiated/turbine-driver-switch
Description: Select which turbine driver to use at runtime.
Author: George Czabania
Latest version: 3.0.0

# Turbine Driver: Switch

> Switch between different turbine drivers using an environment variable.

```javascript
import createDriver from '@stayradiated/turbine-driver-switch'
import createService from '@stayradiated/turbine'

const service = createService({
  name: 'myService',
  driver: createDriver({
    defaultDriver: '@stayradiated/turbine-driver-aws-fanout'
  })
})

...
```


```shell
TURBINE_DRIVER=@stayradiated/turbine-driver-amqp npm start
TURBINE_DRIVER_ARGS_JSON='{"url":"amqp://localhost"}'
```
npm package: @stayradiated/web-audio
Description: Streaming WebAudio source buffer
Author: George Czabania
Latest version: 2.0.1

# @stayradiated/web-audio

So you want the power of the Web Audio API but with support for streaming audio
files? Then this library is for you.

## Todo

 - Find out which browsers support ReadableStreams, because this library depends
on them.

## API Docs

This is just an example of how to use the library at the moment:

```
import WebAudioStream from '@stayradiated/web-audio'

const stream = new WebAudioStream({
  context: new window.AudioContext(),
})

stream.loadSource('/files/audio.mp3')
stream.play()

console.log(stream.audioSource) // underlying audio source
```
npm package: @staysco/clients-core
Description: HTTP clients for Stays platform and CMS
Author: Stays
Latest version: 1.0.0

# @staysco/clients-core

HTTP clients for the Platform and CMS APIs.

## Installation

```bash
# with pnpm
pnpm add @staysco/clients-core

# with npm
npm install @staysco/clients-core
```

## Usage

```ts
import { PlatformClient, CmsClient } from '@staysco/clients-core';
```

## Development

```bash
# install dependencies
pnpm install

# build package
pnpm build

# run tests
pnpm test

# clean build artifacts
pnpm clean
```

## License

MIT
npm package: @staysco/clients-react
Description: React hooks and TanStack Query integrations for Stays platform and CMS clients.
Author: Stays
Latest version: 1.0.0

# @staysco/clients-react

React hooks wrapping the core clients.

## Installation

```bash
pnpm add @staysco/clients-react
npm install @staysco/clients-react
```

## Usage

```tsx
import { usePlatformClient, useCmsClient } from '@staysco/clients-react';
```

## Development

```bash
pnpm install
pnpm build
pnpm clean
```

## License

MIT
npm package: @staysco/cms-types
Description: TypeScript types generated from the Payload CMS.
Latest version: 0.31.0

# @staysco/cms-types

TypeScript types generated from the Payload CMS.

## Installation

```bash
pnpm add @staysco/cms-types
npm install @staysco/cms-types
```

## Usage

```ts
import { Config, User, Page } from '@staysco/cms-types';
```

## Development

```bash
pnpm install
pnpm build
pnpm clean
```

## License

MIT
npm package: @staysco/models
Description: Shared TypeScript data models used across the codebase.
Latest version: 3.0.0

# @staysco/models

Shared TypeScript data models used across the codebase.

## Installation

```bash
pnpm add @staysco/models
npm install @staysco/models
```

## Usage

```ts
import { SomeModel } from '@staysco/models';
```

## Development

```bash
pnpm install
pnpm build
pnpm clean
```

## License

MIT
npm package: @staysco/secrets
Description: Shared secrets manager for Stays services (cms, platform, ui)
Author: Stays Dev Team
Latest version: 1.15.0

# @staysco/secrets

Utility for loading configuration secrets from Google Secret Manager.

## Installation

```bash
pnpm add @staysco/secrets
npm install @staysco/secrets
```

## Usage

```ts
import { getSecrets } from "@staysco/secrets";
```

## Development

```bash
pnpm install
pnpm build
pnpm lint
pnpm typecheck
pnpm clean
```

## License

MIT