open-index/open-npm huggingface dataset:
npm package: @mizchi/flat-pargen
Description: simple parser generator based on regexp groups.
Latest version: 0.0.1

# @mizchi/flat-pargen

simple parser generator based on regexp groups.

```bash
$ npm install @mizchi/idb-ops --save
# or
$ yarn add @mizchi/idb-ops
```

## How to use

```ts
import {compile, $} from "@mizchi/flat-pargen";

// whitespace
const _ = $.expr("\\s*");

const anyLiteral = $.or([
  $.expr("\\d+", (input) => ({ type: "number", value: Number(input) })),
  $.expr("true|false", (input) => ({
    type: "boolean",
    value: Boolean(input),
  })),
  $.expr(`"[^"]*"`, (input) => ({
    type: "string",
    value: input.slice(1, -1),
  })),
]);

const keyPairSeq = [
  $.param("key", $.expr("\\w+")),
  _,
  $.expr("\\:"),
  _,
  $.param("val", anyLiteral as any),
];
const parse = compile(
  $.seq(
    [
      $.expr("\\{"),
      _,
      $.param("head", $.seq(keyPairSeq)),
      $.param<any>(
        "tail",
        $.repeat(
          $.seq([
            // , a: b
            _,
            $.expr(","),
            _,
            ...keyPairSeq,
            _,
          ])
        )
      ),
      _,
      $.expr("\\}"),
    ],
    (input: any) => {
      return [input.head, ...input.tail];
    }
  )
);
console.log(parse(`{ a: 1, b: 2, c: "xxx", d: true }`);
// [
//   { key: "a", val: { type: "number", value: 1 } },
//   { key: "b", val: { type: "number", value: 2 } },
//   { key: "c", val: { type: "string", value: "xxx" } },
//   { key: "d", val: { type: "boolean", value: true } },
// ];

```


## LICENSE

MIT
npm package: @mizchi/idb-ops
Description: simple idb wrapper focused on batch updating.
Latest version: 0.0.1

# @mizchi/idb-ops

simple idb wrapper focused on batch updating.

```bash
$ npm install @mizchi/idb-ops --save
# or
$ yarn add @mizchi/idb-ops
```

## How to use

```ts
import { bulkMutate, iter, openDB } from "@mizchi/idb-ops";

async function main() {
  const database = await openDB(
    // db
    "testdb",
    // version
    1,
    // objectStore names
    ["t1", "t2", "t3"],
    // onUpgrade
    (oldVersion, newVersion, database) => {
      console.log("upgraded", oldVersion, newVersion, database);
    }
  );
  // bulk update
  await bulkMutate(database, [
    ["t1", "set", "a", "x"],
    ["t1", "set", "a2", "xxxx"],
    ["t2", "set", "b", "y"],
    ["t3", "set", "c", "z"],
    ["t1", "delete", "x"],
  ]);

  // async iterator
  for await (const [key, value] of iter(database, "t1")) {
    console.log("t1::", key, value);
  }
}

main().catch(console.error);
```

## Related

- [kvs/packages/indexeddb at master · azu/kvs](https://github.com/azu/kvs/tree/master/packages/indexeddb)
- [treojs/idb-batch: Perform batch operation on IndexedDB](https://github.com/treojs/idb-batch)

## LICENSE

MIT