open-index/open-npm huggingface dataset:
npm package: @poyoho/storage-hook
Description: type stable storage hook
Author: poyoho
Latest version: 1.1.1

# storage-hook

<p align="start">
  <a href="https://www.npmjs.com/package/@poyoho/storage-hook"><img src="https://img.shields.io/npm/v/@poyoho/storage-hook.svg" alt="npm package"></a>
  <a href="https://github.com/poyoho/storage-hook/actions/workflows/ci.yml"><img src="https://github.com/poyoho/storage-hook/actions/workflows/ci.yml/badge.svg?branch=master" alt="build status"></a>
  <a href="https://codecov.io/gh/poyoho/storage-hook"><img src="https://codecov.io/gh/poyoho/storage-hook/branch/master/graph/badge.svg"/></a>
  <!-- <a href="https://packagephobia.com/result?p=@poyoho/storage-hook"><img src="https://packagephobia.com/badge?p=@poyoho/storage-hook"/></a> -->
</p>
<br/>

storage-hook ensures that the original type of js (String / Boolean / Number / Date / Object / Array) is stable in storage (localStorage, sessionStorage and more).

## Installing

Using npm:

```sh
$ npm install @poyoho/storage-hook
```

Using yarn:

```sh
$ yarn add @poyoho/storage-hook
```

Using unpkg CDN:

```
<script src="https://unpkg.com/@poyoho/storage-hook/dist/storage-hook.iife.js"></script>
```

## Example

`useLocalStorage` create a type stable localstorage instance.

```ts
interface User {
  name: string
}

const ls = useLocalStorage({
  key1: Boolean,
  key2: Number,
  key3: String,
  user: Object as unknown as User
})
```

we can use localstorage api and had the expect type.

```ts
const key1 = ls.getItem('key1')
// must be boolean or not will throw a promise error
key1
```

setting storage.

```ts
ls.setItem('key1', true)
```

remove storage key.

```ts
ls.removeItem('key1')
```

clear all storage keys.

```ts
ls.clear()
```

exact the options types.

```ts
type Options = ExactStorageOptions<typeof ls>
```

### about deep object

But there is no way to ensure the type of Object after ts coercion (e.g. `interface User` in this example).

we don't traverse the object to make the object type stable.

```ts
const user = ls.getItem('key4')
// not necessarily exist and type not necessarily be string
user.name
```

Provide two ideas：

1. flat user object by new storage.

```ts
const user = useLocalStorage({
  name: String
  age: Number
})
```

2. validate by yourself.
npm package: @poyro/vitest
Description: [![npm version](https://badge.fury.io/js/%40poyro%2Fvitest.svg)](https://badge.fury.io/js/%40poyro%2Fvitest) | [![docs](https://img.shields.io/badge/poyro-docs-blue)](https://docs.poyro.dev) | [![Discord](https://img.shields.io/discord/1250274948233039883
Latest version: 0.6.6

# @poyro/vitest

[![npm version](https://badge.fury.io/js/%40poyro%2Fvitest.svg)](https://badge.fury.io/js/%40poyro%2Fvitest) | [![docs](https://img.shields.io/badge/poyro-docs-blue)](https://docs.poyro.dev) | [![Discord](https://img.shields.io/discord/1250274948233039883?logo=discord&label=Discord)](https://discord.gg/gmCjjJ5jSf)

This package contains Poyro bindings for the [Vitest](https://github.com/vitest-dev/vitest) test framework. If you're looking for our CLI tool, see the [@poyro/vitest](https://www.npmjs.com/package/poyro) package.

See the [Poyro documentation](https://docs.poyro.dev/#usage) for more information.
npm package: @pozible/image-processor
Description: Process images uploaded to GCS bucket.
Author: spondbob
Latest version: 1.1.2

# @pozible/image-processor
Listening to new objects added to GCS and properly resize images based on given dimensions if needed.

This package is specifically prepared to be deployed on GCF using Pub/Sub triggers. It works hand in hand with [@pozible/signed-upload](https://github.com/pozible/signed-upload) to prepare the metadata and upload the file to GCS bucket.

## Usage
Write `index.js` as follows:

```js
exports.service = require('@pozible/image-processor').default;
```

Then deploy with:
```sh
gcloud beta functions deploy image-processor --entry-point=service --source . --memory=256MB --trigger-bucket <bucket-name> --runtime nodejs10
```
npm package: @pozible/meteor-sha
Description: A simple SHA256 originally ported from [Meteor package](https://github.com/meteor/meteor/tree/devel/packages/sha). Suitable to use when migrating from Meteor's accounts-password to your own handler.
Author: spondbob
Latest version: 1.0.1

# meteor-sha

A simple SHA256 originally ported from [Meteor package](https://github.com/meteor/meteor/tree/devel/packages/sha). Suitable to use when migrating from Meteor's accounts-password to your own handler.
npm package: @pozible/mongoose-yas
Description: Mongoose Yet Another Slug
Author: spondbob
Latest version: 0.6.0

[![npm (scoped)](https://img.shields.io/npm/v/@pozible/mongoose-yas.svg)](https://www.npmjs.com/package/@pozible/mongoose-yas)
[![Build Status](https://travis-ci.org/pozible/mongoose-yas.svg?branch=master)](https://travis-ci.org/pozible/mongoose-yas)

# mongoose-yas
Mongoose Yet Another Slug, follows the same idea to create a slug based on [meteor-friendly-slugs](https://github.com/todda00/meteor-friendly-slugs). This package uses same API and data structure:

```
{
  slug: 'your-slug', // Actual slug can be used in your app
  friendSlugs: { // Should be used by the plugin only
    slug: {
      base: 'your-slug', // Slug result from `slugFrom` without index
      index: 0, // Index of `slug` that is in the same `base`
    }
  }
}
```

## Usage

```
const mongoose = require('mongoose')
const mongooseyas = require('@pozible/mongoose-yas')

const Schema = new mongoose.Schema({
  title: {type: String},
  friendlySlugs: Object,
  publisher: {type: String},
  slug: {type: String, slugFrom: 'title', distinctUpTo: ['publisher']},
})

Schema.plugin(mongooseyas)

const Book = mongoose.model('Book', Schema)

Book.create({
  title: 'i ♥ unicode',
  publisher: 'PUB_1'
}, function(book) {
  console.log(book.slug)
})
```
**Important**: `slug` and `friendlySlugs` are required attributes that must be declared in schema.

## Limitations
- Fixed `slug` and `friendlySlugs` attributes that must be declared in schema to make the plugin works.
- and few other more.
npm package: @pozible/signed-upload
Description: Bootstrapped file upload.
Author: spondbob
Latest version: 1.0.4

[![npm (scoped)](https://img.shields.io/npm/v/@pozible/signed-upload.svg)](https://www.npmjs.com/package/@pozible/signed-upload)
[![Build Status](https://travis-ci.org/pozible/signed-upload.svg?branch=master)](https://travis-ci.org/pozible/signed-upload)

# @pozible/signed-upload
Use [Signed URLs](https://cloud.google.com/storage/docs/access-control/signed-urls) to upload a file straight to Cloud Storage. It returns `optimisticUrl` to access the file once it is uploaded.

## Usage
```js
import signedUpload, { getUrls, upload } from '@pozible/signed-upload'

const {optimisticUrl, signedUrl} = await getUrls(metadata, filePath, config)

await upload(file, metadata, signedUrl)

// Or bootstrap the two commands with
const {optimisticUrl} = await signedUpload(file, metadata, filePath, config)
```

## Arguments
### `metadata`
`dimensions` attribute is used together with Cloud Function listening on bucket's changes to further process the image. Omit it when uploading generic files.
```js
{
  dimensions: {
    imageUrl: {
      width,
      height
    },
    thumbUrl: {
      ...
    },
    ...
  },
  filename: 'original-filename.ext',
  mimetype: 'valid/type'
}
```

### `filePath`
A function to provide a final path to the file in your bucket with uuid as a parameter to give random value to the file name. No need to add extension as it will be automatically added based on given filename in `metadata`.
```js
const filePath = randomId => `/path/to/your/file-with-${randomId}`
const filePath = () => `/path/to/your/original-file-name`
```

### `config`
- `baseUrl` (optional): Add baseUrl to be added to `optimisticPath` to form complete `optimisticUrl`.
- `bucketName`: When it is deployed to Google Cloud Platform it will use current project, else specify one here.