open-index/open-npm huggingface dataset:
npm package: @haxtra/kvstore-sqlite
Description: Basic key-value store for SQLite databases
Author: Hax
Latest version: 0.11.0

# kvstore-sqlite

Basic key-value store for SQLite databases.


## Install
```
npm install @haxtra/kvstore-sqlite
```

## Fineprint

- requires [`super-sqlite3`](https://github.com/haxtra/super-sqlite3) or [`better-sqlite3`](https://github.com/WiseLibs/better-sqlite3) instance as the database driver
- everything is passed through JSON on the way in and out, so:
    - NaN, Infinity become nulls
    - no circular references
    - if data is not JSONable, it will throw


## Usage

Create instance

```js
const KVStore = require('@haxtra/kvstore-sqlite')

const kv = new KVStore(superSqlite3Instance, {
    table: 'kvstore'  // table to use for the store, default "kvstore"
})

// when running for the first time, create the table
kv.createTable()
```

## API

> **Note:** All methods are synchronous.

Set/update value
```js
kv.set(keyName, jsonableData)
```

Retrieve value from the store, falling back to optional default
```js
kv.get(keyName, defaultValue?)
```

Remove key from the store
```js
kv.delete(keyName)
```

Check if key exists, returns timestamp of the last update, or false if key is not set
```js
kv.has(keyName)
```

Get count of stored keys
```js
kv.count()
```

Get array of stored keys
```js
kv.keys(page?, perPage?)
```

Get full store data, as an array of objects
```js
kv.data(page?, perPage?)
```

Remove all data from the store
```js
kv.purge()
```

## Schema

### Create table

Create store table with preconfigured name, defaults to `kvstore`. Returns `true` on success, `false` if table exists, throws on invalid table name.

```js
kv.createTable()
```

### Get schema

Get schema definition as a SQL string, with respect to current config.

```js
kv.getSchema()
```

### Schema file

Get absolute path to `schema.sql` file:

```js
require.resolve('@haxtra/kvstore-sqlite/schema.sql')
```

## License

MIT

![](https://hello.haxtra.com/gh-kvstore-sqlite)
npm package: @haxtra/live-object
Description: Standard javascript object with built-in JSON serialization to file
Author: Hax
Latest version: 0.9.0

# live-object

Standard javascript object with built-in JSON serialization to file. Dreams do come true sometimes.


## Install

`npm i @haxtra/live-object`


## Usage

```js
const liveObject = require('live-object')

const obj = liveObject('/path/to/file')
obj.foo = 'bar'
obj.save()
```

```console
$ cat /path/to/file
> {"foo":"bar"}
```

## API

```js
obj = liveObject(filePath, default?, opts?)

// filePath   - (str) json file path, to load and save (required)
// default    - (obj) used when file at path is not found
// opts.reset - (bool) ignore file even if it exists, force default

obj.save(filePath?, pretty?)

// filePath   - (str) alternative file to save to, used for this save only
//                    does not change/update path given at creation time
// pretty     - (bool) save formatted json, with proper indentation
```

## Rules

- read/write uses sync api
- `save` key is reserved
- `JSON.stringify` rules apply, see [docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#description)


## License

MIT
npm package: @haxtra/logger
Description: Configurable console logger with support for multiple independent groups
Author: Hax
Latest version: 0.9.1

# logger

Configurable console logger with support for multiple independent groups.

[![Screenshot](https://media.haxtra.com/logger.png)](https://media.haxtra.com/logger.png)


## Install

	npm i @haxtra/logger


## Usage

Basic

```js
const Logger = require('@haxtra/logger')

const log = Logger()
log.info('Hello world!')
// > 2027-09-20 19:50:57.810 [app|info] Hello world!
```

Multiple loggers

```js
// equivalent
const apilog = Logger('api')
const apilog = log.spawn('api')
```

Set name and level at creation time

```js
// equivalent
Logger('api', 'warning')
Logger({group:'api', level:'warning'})

log.spawn('api', 'warning')
log.spawn({group:'api', level:'warning'})
```

Log arbitrary objects

```js
log.info('Mysterious object', {foo:'bar'})
// > 2027-09-20 19:50:57.810 [app|info] Mysterious object
// > { foo: 'bar' }
```


## Config

### Global

Configure global settings

```js
// showing defaults
Logger.config({
	level: 'trace',   // global log level, for instances that follow global setting (see Levels below)
	group: true,      // display group name, ie [app|info] vs [info]
	timestamp: true,  // display timestamps
	milli: true,      // display timestamps with millisecond resolution
	color: true,      // use colors in logging
	icons: false,     // use icons instead of level names, ie [I] vs [info]
})
```

Global settings can also be changed via logger instance

```js
log.setGlobalConfig(object)
```

### Instance

Set level

```js
log.setLevel(level)
```

Set global level

```js
log.setGlobalLevel(level)
```

Change group name

```js
log.setGroup(groupName)
```


## Log Levels

By default, instances have a level of `null`, and they follow the global setting. But you can, for example, set `error` as the global level and then `trace` for a particular instance to get a detailed log from just that one particular module.

```js
// info, logs to stdout
log.trace
log.debug
log.dev
log.success
log.ok
log.info
log.notice

// errors, logs to stderr
log.warning
log.alert
log.error
log.exception
log.critical
log.fatal
```
Set levels by:

```js
log.setLevel(level)       // instance level
log.setGlobalLevel(level) // global level
```


## Pausing output

Logging can be paused anytime by:

```js
// cycle instance logging
log.pause()
log.resume()

// cycle global logging
log.pauseGlobal()
log.resumeGlobal()
```


## Remove logger

Delete logger instance by:

```js
log.dispose()
```


## Haxxor Tricks

Access underlying state via these objects:

```js
log.$ // active instances
log.localConfig
log.globalConfig
```


## File logging

Currently `logger` does not support file logging, but you can redirect `stdout` and `stderr` to a file, by using the commands below. Note: you might want to disable color output, or strip ansi control codes on the fly with tools like `ansi2txt` or `sed`.

```console
# log stdout and stderr to one file
node app.js >> app.log 2>&1

# log stdout and stderr to separate files
node app.js >> stdout.log 2>> stderr.log
```


## License

MIT

![](https://hello.haxtra.com/gh-logger)
npm package: @haxtra/xray-react
Description: JavaScript object browser for React.js
Author: Hax
Latest version: 0.9.1

# xray-react

JavaScript object browser for React.js

[Live demo](https://xray.haxtra.com)

![Screenshot](https://media.haxtra.com/xray.png)


## Install

	$ npm i @haxtra/xray-react


## Usage

Basic

	<XRay obj={myObj} />

Disable header

	<XRay obj={myObj} header={false} />

Set custom title

	<XRay obj={myObj} title="My title" />

Start minimized

	<XRay obj={myObj} minimize />
	// same
	<XRay obj={myObj} minimize={true} />

Collapse some keys

	<XRay obj={myObj} collapse={["key1", "key2"]} />
	// collapse nested keys
	<XRay obj={myObj} collapse={["key1.sub1", "key1.sub2"]} />

Collapse all top level keys

	<XRay obj={myObj} collapse="top" />

Collapse everything

	<XRay obj={myObj} collapse />
	// same
	<XRay obj={myObj} collapse={true} />

Collapse everything except

	<XRay obj={myObj} collapseExcept={["key1", "key2"]} />


## Interaction

Clickable areas:

- header title -- show/hide XRay panel
- property -- toggle display of value/subtree
- property : right click -- prompt with path to property
- unknown values -- log undetected object to console


## Caveats

- invisible characters in strings like newline are not displayed
- proxies are not detected, displayed as standard object
- promise status is not detected


## Other ports

- [xray-solid](https://github.com/haxtra/xray-solid)
- [xray-svelte](https://github.com/haxtra/xray-svelte)
- [xray-vue](https://github.com/haxtra/xray-vue)
- [xray-mithril](https://github.com/haxtra/xray-mithril)


## License

MIT

![](https://hello.haxtra.com/gh-xray-react)
npm package: @haxzie/style-fire
Description: A css theme engine to programmatically apply styles
Author: haxzie
Latest version: 1.0.0
Deprecated: duplicate version, please install @haxzie/stylefire

# StyleFire :art::fire:
> A dead simple tiny JS library to manage themes for your websites and web apps - built for css variables
## Install
Embed as a `script`
```
<script src="https://unpkg.com/haxzie/stylefire/dist/bundle.js"></script>
```
Or install with NPM
```
npm i style-fire
```

## Usage
StyleFire works by applying class names to the HTML document with all your css variables wrapped inside it. You can either create the CSS variables using a JSON file or create your own CSS class and pass it to StyleFire.
### Applying a global CSS class to your HTML
```
styleFire.apply('classname');
```
By default, StyleFire saves the theme name so that you can restore the stye whenever the user comes back to your site. Use, `init()` right after loading styleFire lib in your webpage to pickup last saved theme and apply it.
```
styleFire.init();
```
### Load your CSS file using StyleFire
If you want to seperate out the style classes, you can host them seperately and load using styleFire.
```
styleFire.load('themeName', 'link to your css file');
```
```
/* Sample css file with css variables */

.my-theme {
    --color-primary: 'white';
    --color-secondary: 'black';
}
```
### Create a StyleSheet with a JSON 
Creating your style classes using JSON helps you to manage your styles easily and dynamically.
```
// Create a json object with all the attributes and values
const themeLight = {
     color: {
        primary: 'white',
        secondary: 'black',
    },
    font: {
        size: {
            small: '0.8em',
            medium: '1em',
            large: '1.6em'
        }
    },
    background: {
        color: '#eeeeee'
    }
}
styleFire.create('myLightTheme', themeLight).apply();
```
This will generate the following CSS and apply it to your website 
```
.myLightTheme {
    --color-primary: white;
    --color-secondary: black;
    --font-size-small: 0.8em;
    --font-size-medium: 1em;
    --font-size-large: 1.6em;
}
```
Or apply your theme any time after creating!
```
styleFire.apply('style name');
```
Then you can use these CSS variables anywhere in your CSS files.
```
h1 {
    color: var(--font-color-primary);
    font-size: var(--font-size-large);
}
```
## Listen to style changes
StyleFire can take a callback and fire it whenever the themes are changed. Register a callback with `onStyleChanged` to get the details of the changed theme.
```
styleFire.onStyleChanged((theme) => {
    // do whatever you want with the theme
    console.log(`Theme changed to ${theme}`);
})
```

## Future upgrades
- [ ] Enable loading of JSON file from URL
- [ ] Check if the supplied JSON is valid

## Contributing
Check the issues to start contributing
## Lisence
MIT