open-index/open-npm huggingface dataset:
npm package: @sawn/eslint-config
Description: Sawn's ESLint config
Author: sawn
Latest version: 0.0.2
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# @sawn/eslint-config

ESLint config for JavaScript, TypeScript, Vue 2, Vue 3, Prettier.

Forked from [sxzz/eslint-config](https://github.com/sxzz/eslint-config)

## Usage

```bash
pnpm i -D @sawn/eslint-config-basic # JavaScript only
# Or yarn add -D / npm install -D
pnpm i -D @sawn/eslint-config-ts # JavaScript and TypeScript
pnpm i -D @sawn/eslint-config-vue # JavaScript, TypeScript and Vue 2/3 (Auto detect)
pnpm i -D @sawn/eslint-config-prettier # Prettier only
pnpm i -D @sawn/eslint-config # JavaScript, TypeScript, Vue 2/3 and Prettier
```

## Quick start

### Vue 3

```bash
pnpm i -D @sawn/eslint-config
```

```javascript
// .eslintrc.js
module.exports = {
  root: true,
  extends: ['@sawn/eslint-config'],
  rules: {
    // Your custom rules
  },
}
```

```jsonc
// .prettierrc
{
  "singleQuote": true,
  "semi": true,
  "arrowParens": "avoid",
  "jsxSingleQuote": true,
  "endOfLine": "lf",
  "trailingComma": "es5"
}
```

### VSCode

```jsonc
// settings.json
{
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    "typescript",
    "typescriptreact",
    "html",
    "vue",
    "json",
    "json5",
    "jsonc",
    "yaml"
  ],
  "eslint.probe": [
    "javascript",
    "javascriptreact",
    "typescript",
    "typescriptreact",
    "html",
    "vue",
    "json",
    "json5",
    "jsonc",
    "yaml"
  ]
}
```
npm package: @sawn/prettier-config
Description: Shared Prettier configuration file.
Author: sawn
Latest version: 0.0.3
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# Shared Prettier Configuration ✨

[![npm (scoped)](https://img.shields.io/npm/v/@sawn/prettier-config.svg?style=flat-square)](https://www.npmjs.com/package/@sawn/prettier-config)

## Installation

To install the module use the following commands:

```bash
$ pnpm add -D prettier @sawn/prettier-config
```

## Usage

Add to `package.json`:

```json
{
  "prettier": "@sawn/prettier-config"
}
```
npm package: @sawn/tsconfig
Description: Shared tsconfig file.
Author: sawn
Latest version: 0.0.2

# Shared TypeScript Configuration ✨

[![npm (scoped)](https://img.shields.io/npm/v/@sawn/tsconfig.svg?style=flat-square)](https://www.npmjs.com/package/@sawn/tsconfig)

## Installation

To install the module use the following commands:

```bash
$ pnpm add -D @sawn/tsconfig
```

## Usage

Add to `tsconfig.json`

```json
{
  "extends": "@sawn/tsconfig"
}
```
npm package: @sawport/react-native-sdk
Description: Sawport SDK
Author: sawport
Latest version: 1.0.2

# @sawport/react-native-sdk

Sawport SDK

## Installing single dependency

```sh
yarn add @sawport/react-native-sdk
```

### Installing required peer dependencies
> Dependencies are required for the sdk to function
```sh
yarn add react-native-audio-recorder-player react-native-calendars react-native-date-picker @react-native-documents/picker \
react-native-incall-manager react-native-localize react-native-svg react-native-webrtc
```

# Peer Dependencies Setup
> Make sure to follow setup instructions from the peer dependencies documentation sites.
> Most especially react-native-audio-recorder-player and react-native-webrtc


## Usage

```js
import {Widget, setConfig} from '@sawport/react-native-sdk';

setConfig({host: 'https://{BACKEND_DOMAIN}', baseURL: 'https://{BACKEND_DOMAIN}/api/v1/' });

function App() {
  return <Widget user={AUTH_USER} projectId={PROJECT_ID} style={styles.widget} />;
}
```

# API References
## Widget
Sawport React Native SDK's widget component
### Type
- React Component
### Props
- [user](#user)
- [projectId](#projectid)
- [style](https://reactnative.dev/docs/stylesheet)
- [launcherWrapperStyle](https://reactnative.dev/docs/stylesheet)
- [launcherStyle](https://reactnative.dev/docs/stylesheet)

## setConfig
### Type
- Function(config)
### Props
- [config](#sawportconfig)

## sawportConfig
The Sawport configuration object
### Type
- Object
### user
- name: `customer name to populate in the widget`
- mobile: `customer phone number to populate in the widget`
- email: `customer email to populate in the widget`
### projectId
`The Enterprise's ID from the Dashboard`

## Contributing

See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.

## License

MIT
npm package: @saws/cli
Description: <div align='center'>
Latest version: 1.0.11

<div align='center'>

# SAWS CLI

CLI for interacting with your SAWS application.

</div>

## Table of Contents
- [Installation](#installation)
- [Commands](#commands)

## Installation <a id='installation'>

From the command line run:
```bash
npm install @saws/cli
```

Then run `npx saws init` to initialize your SAWS application in your current directory.

## Commands <a id='commands'>

These commands are the base commands that come with the `saws` cli. But other services in your `saws.js` can add additional commands to the `saws` cli. For example: [`secrets` command](../secrets/README.md#commands).

### `init`

```bash
npx saws init
```

This command will initialize a SAWS application in your current working directory.

It will
 - Install any needed dependencies
 - Create a `.gitignore`
 - Create a `tsconfig.json`
 - Create your `saws.js` config file

### `dev`

```bash
npx saws dev
```

This command will intitialize any new services in your `saws.js` file and stand up a local development environment for your application.

### `deploy`

```bash
npx saws deploy --stage <stage>
```

This command will deploy all the services in your `saws.js` file to AWS. You will need to have your AWS session configured in your terminal for this command to succeed.

### `execute`

```bash
npx saws execute ./path/to/script.ts --stage <stage>

```
This command will execute a script against your application. `stage` by default will be local. If your script depends on services being running locally, you will need to run them using `npx saws dev` in another terminal tab/window.
npm package: @saws/email
Description: <div align='center'>
Latest version: 1.0.11

<div align='center'>

# Email

Service and library for sending email in your application.

</div>

## Table of Contents
- [Installation](#installation)
- [Development](#development)
- [Deployment](#deployment)
- [Services](#services)
  - [EmailService](#email-service)
- [When used as a dependency](#when-used-as-a-dependency)
- [Libraries](#libraries)
  - [Email](#email-library)

## Installation <a id='installation'>

From the command line run:
```bash
npm install @saws/email
```

Then add the included service ([`EmailService`](#email-service)) to your `saws.js` file.

## Development <a id='development'>

In development this service does nothing. There is no local infrastructure required for how the library implements email sending.

Any emails sent in development will just be logged to the console.

## Deployment <a id='deployment'>

In a deployed environment, email sending is managed by AWS SES. One thing to note is that by default all SES accounts are by default limited to verified domains and emails. So if you'd like to use SES to send to non verified emails, you will need to go through their process to have your account removed from the sandbox.

When you deploy an `EmailService` no infrastructure is stood up. But any services that depend on an `EmailService` will have their permissions configured to be able to send emails via SES.

## Services <a id='services'>

`@saws/email` has a single service that is includes, `EmailService`.

### `EmailService` <a id='email-service'>

You can require the `EmailService` and use it in your `saws.js` file like so:
```js
const { EmailService } = require('@saws/email/email-service')

// will almost always be used as a dependency to another service
const email = new EmailService({
  name: 'my-email-service'
})
```

The `EmailService` constructor accepts the following options:

#### `name: string`
The name of your service. This should be unique across all of your services.

#### `dependencies: ServiceDefinition[]`
An array of all of the other services this service depends on. This will ensure that permissions, environment variables, and execution order are all set up.

## When used as a dependency <a id='when-used-as-a-dependency'>

When an email service is used as a dependency, it does not inject any environment variables into dependant services.

## Libraries <a id='libraries'>

`@saws/email` a single library for sending email, `Email`

### Email <a id='email-library'>

The `Email` library is a class that allows you send emails via SES in production, or log to the terminal in development.

Example usage:

```ts
import { Email } from '@saws/email/email-library'

const client = new Email()
```

#### `sendEmail(options: { to: string[]; subject: string; type: "html" | "text"; message: string; source: string; })`
Sends an email.
npm package: @saws/translate
Description: <div align='center'>
Latest version: 1.0.11

<div align='center'>

# Translate

Service and library to make using AWS's translation services easier to use.

</div>

## Table of Contents
- [Installation](#installation)
- [Development](#development)
- [Deployment](#deployment)
- [Services](#services)
  - [TranslateService](#translate-service)
- [When used as a dependency](#when-used-as-a-dependency)
- [Libraries](#libraries)
  - [Translate](#translate-library)

## Installation <a id='installation'>

From the command line run:
```bash
npm install @saws/translate
```

Then add the [`TranslateService`](#translate-service) to your `saws.js` file.

## Development <a id='development'>

When running your SAWS application in development, this service will do nothing. Important to note that the `Translate` library will still hit AWS's translation services when running in development.

## Deployment <a id='deployment'>

When you deploy a `TranslateService` it will not create any resources in AWS. This service primarily functions as a way to ensure any dependant services have the right permissions set up.

## Services <a id='services'>

`@saws/translate` includes one service, `TranslateService`.

### `TranslateService` <a id='translate-service'>

You can require the `TranslateService` and use it in your `saws.js` file like so:
```js
const { TranslateService } = require('@saws/translate/translate-service')

// will exclusively be used as a dependency to other services
const translate = new TranslateService({
  name: 'translate-service',
})
```

The `TranslateService` constructor accepts the following options:

#### `name: string`
The name of your service. This should be unique across all of your services.

#### `dependencies: ServiceDefinition[]`
An array of all of the other services this service depends on. This will ensure that permissions, environment variables, and execution order are all set up.

## When used as a dependency <a id='when-used-as-a-dependency'>

When a `TranslateService` is used as a dependency, it will not attach any environment variables to the dependant service.

## Libraries <a id='libraries'>

`@saws/translate` includes a `Translate` class that can be used to get machine translations from AWS's translation services.

### `Translate` <a id='translate-library'>

The `Translate` class can be used as follows:

```ts
import { Translate } from '@saws/translate/translate-library'

const client = new Translate()

const result = await client.translateText('Some text', sourceLanguage, targetLanguage)
```

#### `translateText(text: string, sourceLanguage: string, targetLanguage: string): Promise<string>`
This function will use AWS's translation services to perform a machine translation of the provided text from the source language to the target language.
npm package: @saws/website
Description: <div align='center'>
Latest version: 1.0.11

<div align='center'>

# Website

Service for building websites using [Vite](https://vitejs.dev).

</div>

## Table of Contents
- [Installation](#installation)
- [Development](#development)
- [Deployment](#deployment)
- [Services](#services)
  - [WebsiteService](#website-service)
- [When used as a dependency](#when-used-as-a-dependency)
- [Libraries](#libraries)

## Installation <a id='installation'>

From the command line run:
```bash
npm install @saws/website
```

Then add the included service, [`WebsiteService`](#website-service) to your `saws.js` file.

## Development <a id='development'>

In development, a `WebsiteService` will use the Vite dev server to build and serve your website. It will also write any of your dependant service's environment variables to a `.env` file for Vite to read and inject into your build.

For new `WebsiteService`s that have just been added to your `saws.js` file. SAWS will create a hello world world website for you.

## Deployment <a id='deployment'>

When you deploy a `WebsiteService`, a number of resources will be stood up and configured for you:
 - An S3 bucket will be created that is configured to be used as a website.
 - A Cloudfront distribution that serves content out of the above S3 bucket.
 - A Route 53 Record Set Group to point your domain at the above Cloudfront distribution.

## Services <a id='services'>

`@saws/website` includes the `WebsiteService`

### `WebsiteService` <a id='website-service'>

You can require the `WebsiteService` and use it in your `saws.js` file like so:
```js
const { WebsiteService } = require('@saws/website/website-service')

const website = new WebsiteService({
  name: 'my-website'
})

module.exports = website
```

The `WebsiteService` constructor accepts the following options:

#### `name: string`
The name of your service. This should be unique across all of your services.

#### `dependencies: ServiceDefinition[]`
An array of all of the other services this service depends on. This will ensure that permissions, environment variables, and execution order are all set up.

#### `port?: number`
The port to run the Vite dev server on. If the provided port is in use, a different port will automatically be chosen.

#### `rootDir?: string`
Used if you would like the service to point at a different directory for your `WebsiteService` other than it's name.

#### `domain?: string`
A domain name that you would like to use for your website. You must own this domain and have it configured in Route 53.

#### `env?: Record<string, string>`
Additional environment variables to include in your Vite build.

#### `certificateArn?: string`
The AWS Arn to the certificate you'd like to use for your website to enable HTTPs.

## When used as a dependency <a id='when-used-as-a-dependency'>

When a `WebsiteService` is used as a dependency, it does not attach any environment variables to the dependant services.

## Libraries <a id='libraries'>

`@saws/website` does not include any libraries with it.
npm package: @sawtaytoes/react-lazyimport
Description: A super simple library which reveals the method `lazyImport` for use in React component loading.
Author: Kevin Ghadyani
Latest version: 1.0.0

# React Lazy Import

This is a super simple library which reveals the method `lazyImport` for use in React component loading.

If you want to asynchronously load components with React, you have to import `lazy`, pass it a callback, and `import` that component yourself.

Instead, you could use this `lazyImport` library instead to cleanup the readability instead.

For more information, read my [reference article](https://medium.com/@Sawtaytoes/async-react-components-in-react-router-w-suspense-a86ade1176dc) which covers this topic and goes into detail about why you'd want this functionality.
npm package: @sawtooth7799/fizzbuzz
Description: A Javascript implementation of FizzBuzz.
Author: Satoshi Sawaguchi
Latest version: 1.0.0

# fizzbuzz

A Javascript implementation of FizzBuzz.

## Installation

```sh
$ npm install @sawtooth7799/fizzbuzz
```

## Usage

### In Javascript code

```js
const fizzbuzz = require('@sawtooth7799/fizzbuzz')

fizzbuzz(1) // '1'
fizzbuzz(2) // '2'
fizzbuzz(3) // 'Fizz'
fizzbuzz(5) // 'Buzz'
fizzbuzz(15) // 'FizzBuzz'
```

### From the command line

```sh
$ npx fizzbuzz 1
1
$ npx fizzbuzz 2
2
$ npx fizzbuzz 3
Fizz
$ npx fizzbuzz 5
Buzz
$ npx fizzbuzz 15
FizzBuzz
```
npm package: @sawyerclick/layercake
Description: Layer Cake  [<img src="https://raw.githubusercontent.com/mhkeller/layercake.graphics/main/static/layercake-logo-500x400.png" width="115" align="right" alt="layercake-logo">](https://mhkeller.github.io/layercake) ===
Latest version: 7.2.2

Layer Cake  [<img src="https://raw.githubusercontent.com/mhkeller/layercake.graphics/main/static/layercake-logo-500x400.png" width="115" align="right" alt="layercake-logo">](https://mhkeller.github.io/layercake)
===

> a framework for mostly-reusable graphics with [svelte](https://github.com/sveltejs/svelte)

[![Travis (.org) branch](https://img.shields.io/travis/mhkeller/layercake/master.svg?style=flat-square)](https://travis-ci.org/mhkeller/layercake) [![npm version](https://img.shields.io/npm/v/layercake.svg?style=flat-square)](https://npmjs.org/package/layercake)

 🍰 [See examples](https://layercake.graphics)
 🍰 [Read the guide](https://layercake.graphics/guide)
 🍰 [API docs](https://layercake.graphics/guide#layercake-props)
 🍰 [View the Component Gallery](https://layercake.graphics/components)
 🍰 [Try the starter template](https://github.com/mhkeller/layercake-template)
 🍰

## Install

```sh
npm install --save layercake
```

## Example

```svelte
<script>
  // The library provides a main wrapper component
  // and a bunch empty layout components...
  import { LayerCake, Svg, Html, Canvas } from 'layercake';

  // ...that you fill with your own chart components,
  // that live inside your project and which you
  // can copy and paste from here as starting points.
  import AxisX from './components/AxisX.svelte';
  import AxisY from './components/AxisY.svelte';
  import Line from './components/Line.svelte';
  import Scatter from './components/Scatter.svelte';
  import Labels from './components/Labels.svelte';

  const data = [{ x: 0, y: 1 }, { x: 1, y: 2 }, { x: 2, y: 3 }];
</script>

<style>
  .chart-container {
    width: 100%;
    height: 500px;
  }
</style>

<div class="chart-container">
  <LayerCake
    x='x'
    y='y'
    {data}
  >
    <Svg>
      <AxisX/>
      <AxisY/>
      <Line color='#f0c'/>
    </Svg>

    <Canvas>
      <Scatter color='#0fc'/>
    </Canvas>

    <Html>
      <Labels/>
    </Html>
  </LayerCake>
</div>
```

## License

MIT
npm package: @sawyerh/firestore-highlights
Description: Firestore models used for storing highlights and their corresponding data
Author: Sawyer Hollenshead
Latest version: 3.3.2

> Firestore models used for storing highlights and their corresponding data

## Usage

```js
const admin = require("firebase-admin");
const firestore = admin.firestore();

// Require a single model
const Volume = require("@sawyerh/firestore-highlights/Volume")(firestore);

// or require multiple at once
const { Entity, Volume } = require("@sawyerh/firestore-highlights")(firestore);
```
npm package: @sawyerhopkins/progressive-image
Description: A dead simple progressive-image module for Vanilla JavaScript and Vue.js 1.0+ & 2.0+
Author: ccforward
Latest version: 1.2.1

# progressive-image

A dead simple progressive-image module for Vanilla JavaScript and Vue.js 1.0+ & 2.0+

![gif](https://github.com/ccforward/cc/raw/master/Blog/pic/progressive-0.gif)

## GitHub

[GitHub - progressive-image](https://github.com/ccforward/progressive-image)

## NPM

[![NPM version][npm-image]][npm-url]

[NPM - progressive-image](https://www.npmjs.com/package/progressive-image)

## update

#### @v1.1.0
add the `scale` option for origin image animation

## Install

```shell
$ npm install progressive-image --save
 
$ yarn add progressive-image
```

## For Vanilla JS

### demo

[progressive-image-demo](https://ccforward.github.io/progressive-image/index.html)

[progressive-image-vue-demo](https://ccforward.github.io/progressive-image/example/demo-vue.html)

### Usage

#### import css
```html
<link href="./node_modules/progressive-image/dist/index.css" rel="stylesheet" type="text/css">
```

or

```html
<link href="//unpkg.com/progressive-image/dist/index.css" rel="stylesheet" type="text/css">
```

#### HTML

```html
<main id="app">
  <div class="progressive">
    <img class="preview lazy" data-src="http://7xiblh.com1.z0.glb.clouddn.com/progressive/1.jpg" src="http://7xiblh.com1.z0.glb.clouddn.com/progressive/r1.jpg" />
  </div>
  <div class="progressive">
    <img class="preview lazy" data-src="http://7xiblh.com1.z0.glb.clouddn.com/progressive/2.jpg" src="http://7xiblh.com1.z0.glb.clouddn.com/progressive/r2.jpg" />
  </div>
</main>
<script src="./dist/index.js"></script>
```

#### JS

```js
(function(){
  new Progressive({
    el: '#app',
    lazyClass: 'lazy',
    removePreview: true
    scale: true
  }).fire()
})()

```

## For Vue.js

#### import css
```html
<link href="./node_modules/progressive-image/dist/index.css" rel="stylesheet" type="text/css">
```

or

```html
<link href="//unpkg.com/progressive-image/dist/index.css" rel="stylesheet" type="text/css">
```

#### HTML

```html
<main id="app">
  <template v-for="item in imgs">
    <div class="space"></div>
    <div class="progressive">
      <img class="preview" v-progressive="item.src" :data-srcset="item.srcset" :src="item.preview" />
    </div>
  </template>
</main>
```

#### JS

```js
import Vue from 'vue'
import progressive from 'progressive-image/dist/vue'

Vue.use(progressive, {
  removePreview: true,
  scale: true
})

new Vue({
  name: 'demo',
  el: '#app',
  data: {
    imgs: [
      {
        src: 'http://7xiblh.com1.z0.glb.clouddn.com/progressive/2.jpg',
        preview: 'http://7xiblh.com1.z0.glb.clouddn.com/progressive/r2.jpg'
      },
      {
        src: 'http://7xiblh.com1.z0.glb.clouddn.com/progressive/3.jpg',
        preview: 'http://7xiblh.com1.z0.glb.clouddn.com/progressive/r3.jpg'
      }
    ]
  }
})
```


## build

#### build dist

```shell
npm run build
```

#### build demo

```shell
npm run demo
```

[npm-url]: https://www.npmjs.com/package/progressive-image
[npm-image]: https://img.shields.io/npm/v/progressive-image.svg
npm package: @saxjst/koa-joi-validator
Description: Koa payload validator middleware using joi
Author: saxjst
Latest version: 0.0.1

# Koa-Joi-Validator

> Middleware validate a koa request using joi schemas


[![Build Status](https://travis-ci.org/saxjst/koa-joi-validator.svg?branch=master)](https://travis-ci.org/saxjst/koa-joi-validator)
[![Coverage Status](https://coveralls.io/repos/github/saxjst/koa-joi-validator/badge.svg?branch=master)](https://coveralls.io/github/saxjst/koa-joi-validator?branch=master)
[![Maintainability](https://api.codeclimate.com/v1/badges/841af7743a474bb61775/maintainability)](https://codeclimate.com/github/saxjst/koa-joi-validator/maintainability)
[![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier/)


## Features

- Allows schemas to validate themselves (no joi version dependencies)
- Validate query, params, header and body with dedicated schemas

### Usage

#### As global middleware

```javascript
const Koa = require("koa");
const Joi = require("@hapi/joi");
const validator = require("koa-joi-validator");

const app = new Koa();

const schemas = {
  headers: {
    // Request headers Joi validation object
    "x-request-id": joi
      .string()
      .alphanum()
      .length(32)
  },
  query: {
    // URL query string Joi validation object
    userid: joi.string().required()
  },
  params: {
    // URL path parameters Joi validation object
  },
  body: {
    // POST body Joi validation object
  }
};

app.use(validate(schemas));

app.use(async ctx => {
  ctx.body = "Hello World";
});

app.listen(5000);
```

#### As router middleware

```js
const validator = require("koa-joi-validator");
const router = new Router()

const schemas = {
  body: {
    username: Joi.string().required(),
    password: Joi.string().required()
  }
})

router.post('/login', validator(schemas), async ctx => {
  const { username, password } = ctx.body
  const response = await login(username, password)
  ctx.body = response
})
```

## API

### validator(schemas) ⇒ <code>function</code>

Generate a Koa middleware function to validate a request using
the provided validation objects.

**Returns**: A validation middleware function.

| Param             | Type                | Description    |
| ----------------- | ------------------- | -------------- |
| schemas           | `Object` |                |
| [schemas.headers] | `Object` | headers schema |
| [schemas.params]  | `Object` | params schema  |
| [schemas.query]   | `Object` | query schema   |
| [schemas.body]    | `Object` | body schema    |


## License

MIT © [saxjst](https://saxjst.com)
npm package: @saxjst/sort-of
Description: Sort objects by the value of their key
Author: saxjst
Latest version: 1.0.1

# sort-of

> Sort objects by the value of their key

[![Build Status](https://travis-ci.org/saxjst/sort-of.svg?branch=master)](https://travis-ci.org/saxjst/sort-of)
[![Coverage Status](https://coveralls.io/repos/github/saxjst/sort-of/badge.svg?branch=master)](https://coveralls.io/github/saxjst/sort-of?branch=master)
[![Maintainability](https://api.codeclimate.com/v1/badges/841af7743a474bb61775/maintainability)](https://codeclimate.com/github/saxjst/sort-of/maintainability)
[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/saxjst/sort-of.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/saxjst/sort-of/context:javascript)
[![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier/)

## Install

```
$ npm install @saxjst/sort-of
```

## Usage

```js
const sortOf = require('@saxjst/sort-of');

const people = [
  {
    name: "alice",
    age: 15
  },
  {
    name: "bob",
    age: 9
  },
  {
    name: "aaron",
    age: 12
  },
]

sortOf(people, ['age'], 'asc');
// [
//   {
//     name: "bob",
//     age: 9
//   },
//   {
//     name: "aaron",
//     age: 12
//   },
//   {
//     name: "alice",
//     age: 15
//   }
// ]
```

## API

## sortOf(arr, [path], command) ⇒ `Number[]` \| `Object[]`
Sort objects by the value of their key

**Kind**: global function  
**Returns**: `Number[]` \| `Object[]` - the sorted array  

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| arr | `Number[]` OR `Object[]` |  | the array to retrieve the value from. |
| [path] | `String[]` | `[]` | the key to sort by |
| command | `String` |  | asc or desc |



## License

MIT © [saxjst](https://saxjst.com)
npm package: @saxorg/temporal_json
Description: [![npm-ci](https://github.com/noxasaxon/temporal_apig/actions/workflows/npm-ci.yml/badge.svg)](https://github.com/noxasaxon/temporal_apig/actions/workflows/npm-ci.yml)
Latest version: 0.0.2

# temporal-json-node
[![npm-ci](https://github.com/noxasaxon/temporal_apig/actions/workflows/npm-ci.yml/badge.svg)](https://github.com/noxasaxon/temporal_apig/actions/workflows/npm-ci.yml)

NodeJS bindings to the [Temporal API Gateway JSON Encoder](../temporal-json/README.md)


## Commands

### Build
```shell
cd crates/temporal-node-json
yarn install
yarn build
yarn test
```

### Publish
```shell
npm version patch
git tag -a <version> -m "<version>"
git push --follow-tags
```

**Notes**
- Publish will only occur if the commit message is just the version number ex.  1.0.0
- Changes to some files like `*.md` won't trigger the CI pipeline.
npm package: @saxorg/temporal_json-linux-x64-gnu
Description: This is the **x86_64-unknown-linux-gnu** binary for `@saxorg/temporal_json`
Latest version: 0.0.2

# `@saxorg/temporal_json-linux-x64-gnu`

This is the **x86_64-unknown-linux-gnu** binary for `@saxorg/temporal_json`
npm package: @saxorg/temporal_json-win32-x64-msvc
Description: This is the **x86_64-pc-windows-msvc** binary for `@saxorg/temporal_json`
Latest version: 0.0.2

# `@saxorg/temporal_json-win32-x64-msvc`

This is the **x86_64-pc-windows-msvc** binary for `@saxorg/temporal_json`
npm package: @saxs/json-path-transform
Description: Transform JSON objects using JSONPath syntax
Latest version: 0.4.2

# @saxs/json-path-transform

Transforms JSON objects using a path-based approach.

## Description

This package provides a simple way to transform JSON objects using a path-based approach.

The purpose is to make it possible to write declarative transformations for json objects, hence make it useable in a configuration file or from user inputs.

## Installation

Using npm

```bash
npm install @saxs/json-path-transform
```

Using yarn

```bash
yarn add @saxs/json-path-transform
```

Using pnpm

```bash
pnpm add @saxs/json-path-transform
```

## Usage

The schema defines the transformation rules. The keys are the target keys and the values are the paths to the source keys.

```typescript
import { PathTransform } from '@saxs/json-path-transform';

const schema = {
  name: '$.user.name',
  age: '$.user.age',
};

const data = {
  user: {
    name: 'John Doe',
    age: 30,
  },
};

const transformer = new PathTransform(schema).compile();

console.log(transformer(data)); // { name: 'John Doe', age: 30 }
```

## Syntax

The JSONPath syntax is used to define the paths. The package uses the `jsonpath-plus` package under the hood to resolve the paths.

Exmaples can be found at [https://goessner.net/articles/JsonPath/](https://goessner.net/articles/JsonPath/).

### Root ($) key

The root key can be used to define the root of the object at any given depth. This copies the main object to that level.

```typescript
import { PathTransform } from '@saxs/json-path-transform';

const schema = {
  $: '$.user',
};

const data = {
  user: {
    name: 'John Doe',
    age: 30,
  },
};

const transformer = new PathTransform(schema).compile();

console.log(transformer(data)); // { name: 'John Doe', age: 30 }
```

## Performance

The performance is dependant on the complexity of the schema and the size of the data. The package makes a AOT compilation of the schema to make the transformation as fast as possible, and uses `jsonpath-plus` package under to hood to resolve results from each path.

On a M1 Macbook Air (16GB RAM) we can expect the following performance as seen under the `benchmark` folder.

| Test Name     | ops/sec   | Confidence Interval |
| ------------- | --------- | ------------------- |
| root          | 4,907,733 | ±0.20%              |
| allAuthors    | 479,267   | ±0.35%              |
| allAuthorsDot | 1,007,505 | ±1.30%              |
| addKey        | 449,904   | ±0.76%              |
npm package: @saxs/json-traverse
Description: Traverse JSON objects
Latest version: 0.2.1

# Traverse

## Usage

The Traverse class is a simple way to traverse a JSON object. It can be used to find a specific value, or to modify the object with either the "forEach" or "map" methods.

### Example

Using the "forEach" method to modify the object:

```javascript
// Using the "forEach" method to modify the object
import { traverse } from "@saxs/traverse

const data = {
  name: "John",
  age: 30,
  cars: {
    car1: "Ford",
    car2: "BMW",
    car3: "Fiat"
  }
};

const result = traverse(data).forEach((value, node) => {
  if (node.key === "car1") {
    node.update("Toyota")
  }
});

console.log(result);

const isEqual = data === result; // true (data is mutated)
```

Likewise, using the "map" method to modify the object:

```javascript
// Using the "map" method to create a modified
import { traverse } from "@saxs/traverse

const data = {
  name: "John",
  age: 30,
  cars: {
    car1: "Ford",
    car2: "BMW",
    car3: "Fiat"
  }
};

const result = traverse(data).map((value, node) => {
  if (node.key === "car1") {
    node.update("Toyota")
  }
});

console.log(result);

const isEqual = data === result; // false (result is a new object)
```