<commit_before># datascript-mori

Wrapper for datascript interplay with mori

## Why?

Datascript is greatful project - [an immutable in-memory database and Datalog query engine in Clojure and ClojureScript](https://github.com/tonsky/datascript). It is very useful for managing very big and complex application state in frontend application.

Datascript is written in ClojureScript. Also Datascript designed for using from ClojureScript, but it has [JS dedicated API](https://github.com/tonsky/datascript/wiki/Javascript-API#js-public-api). However usage Datascript from JS has problems:
 - functions for quering - [q](https://github.com/tonsky/datascript/blob/master/src/datascript/js.cljs#L69), [pull](https://github.com/tonsky/datascript/blob/master/src/datascript/js.cljs#L74), [pull_many](https://github.com/tonsky/datascript/blob/master/src/datascript/js.cljs#L80), [index_range](https://github.com/tonsky/datascript/blob/master/src/datascript/js.cljs#L145) etc. - convert result of query into JS data structures(Array, Object). JS data structures is mutable data strutures with very bad API. Also when you use mutable data structures in React app, you can not use ["pure render" optimisations](https://facebook.github.io/react/docs/pure-render-mixin.html). [See more cases for immutability](https://facebook.github.io/react/docs/advanced-performance.html#immutable-js-to-the-rescue). `datascript-mori` open access for all Datascript API and some helpers.
 - Datascript includes ClojureScript Runtime. It is very big amount of code includes extensive
 set of immutable data structures. However it is useless without [mori](https://github.com/swannodette/mori). But when you're importing mori and Datascript, the size of your application will grow twice(because mori and Datascript are two separate packages for Javascript). `datascript-mori` join their codebase.

## Setup

 - (**Recommended**) Install from [NPM](https://www.npmjs.org/package/datascript-mori)
 ```
 npm install datascript-mori
 ```
 - Download [latest release](https://github.com/typeetfunc/datascript-mori/releases/latest)

## Usage

 - (**Recommended**) Using EcmaScript 2015 modules:
 ```js
import {
  datascript, // This is contain datascript object
  mori,       // This is contain mori object
  helpers     // This is contain helpers for conversions from CLJS
} from 'datascript-mori';

const {
  core, // This is pure DataScript CLJS API without any conversions
  js    // This is DataScript JS API
} = datascript;
 ```

 - Using CommonJS modules:
 ```js
var datascript_mori = require('datascript-mori');

var mori = datascript_mori.mori;
var datascript_js = datascript_mori.datascript.js;
var datascript_core = datascript_mori.datascript.core;
var helpers = datascript_mori.helpers;
 ```

 - (**Not recommended**) Using tag <script> in Browser:
```html
<script src="datascript-mori.js"></script>
<script>
  var mori = datascript_mori.mori;
  var datascript_js = datascript_mori.datascript.js;
  var datascript_core = datascript_mori.datascript.core;
  var helpers = datascript_mori.helpers;
</script>
```

## API Overview

- `datascript_mori.datascript.core` - is a [CLJS DataScript API](https://github.com/tonsky/datascript/wiki/API-overview). All functions accept CLJS data structures and return back CLJS data structures(i.e mori values). All names of these functions converts("munging") with symbols allowed in JS for function name. [See mapping list](https://github.com/typeetfunc/datascript-mori/wiki/Mapping-names-of-functions).
- `datascript_mori.datascript.js` - is a [JS DataScript API](https://github.com/tonsky/datascript/wiki/Javascript-API)<commit_msg>docs(README): fix structure of markdown<commit_after># datascript-mori

Wrapper for datascript interplay with mori

## Why?

Datascript is greatful project - [an immutable in-memory database and Datalog query engine in Clojure and ClojureScript](https://github.com/tonsky/datascript). It is very useful for managing very big and complex application state in frontend application.

Datascript is written in ClojureScript. Also Datascript designed for using from ClojureScript, but it has [JS dedicated API](https://github.com/tonsky/datascript/wiki/Javascript-API#js-public-api). However usage Datascript from JS has problems:
 - functions for quering - [q](https://github.com/tonsky/datascript/blob/master/src/datascript/js.cljs#L69), [pull](https://github.com/tonsky/datascript/blob/master/src/datascript/js.cljs#L74), [pull_many](https://github.com/tonsky/datascript/blob/master/src/datascript/js.cljs#L80), [index_range](https://github.com/tonsky/datascript/blob/master/src/datascript/js.cljs#L145) etc. - convert result of query into JS data structures(Array, Object). JS data structures is mutable data strutures with very bad API. Also when you use mutable data structures in React app, you can not use ["pure render" optimisations](https://facebook.github.io/react/docs/pure-render-mixin.html). [See more cases for immutability](https://facebook.github.io/react/docs/advanced-performance.html#immutable-js-to-the-rescue). `datascript-mori` open access for all Datascript API and some helpers.
 - Datascript includes ClojureScript Runtime. It is very big amount of code includes extensive
 set of immutable data structures. However it is useless without [mori](https://github.com/swannodette/mori). But when you're importing mori and Datascript, the size of your application will grow twice(because mori and Datascript are two separate packages for Javascript). `datascript-mori` join their codebase.

## Setup

 - (**Recommended**) Install from [NPM](https://www.npmjs.org/package/datascript-mori)
 ```
 npm install datascript-mori
 ```
 - Download [latest release](https://github.com/typeetfunc/datascript-mori/releases/latest)

## Usage

 - (**Recommended**) Using EcmaScript 2015 modules:

 ```js
import {
   datascript, // This is contain datascript object
   mori,       // This is contain mori object
   helpers     // This is contain helpers for conversions from CLJS
} from 'datascript-mori';

const {
   core, // This is pure DataScript CLJS API without any conversions
   js    // This is DataScript JS API
} = datascript;
 ```

 - Using CommonJS modules:

 ```js
var datascript_mori = require('datascript-mori');

var mori = datascript_mori.mori;
var datascript_js = datascript_mori.datascript.js;
var datascript_core = datascript_mori.datascript.core;
var helpers = datascript_mori.helpers;
 ```

 - (**Not recommended**) Using tag <script> in Browser:

```html
<script src="datascript-mori.js"></script>
<script>
  var mori = datascript_mori.mori;
  var datascript_js = datascript_mori.datascript.js;
  var datascript_core = datascript_mori.datascript.core;
  var helpers = datascript_mori.helpers;
</script>
```

## API Overview

- `datascript_mori.datascript.core` - is a [CLJS DataScript API](https://github.com/tonsky/datascript/wiki/API-overview). All functions accept CLJS data structures and return back CLJS data structures(i.e mori values). All names of these functions converts("munging") with symbols allowed in JS for function name. [See mapping list](https://github.com/typeetfunc/datascript-mori/wiki/Mapping-names-of-functions).
- `datascript_mori.datascript.js` - is a [JS DataScript API](https://github.com/tonsky/datascript/wiki/Javascript-API)
{'fraction_non_alphanumeric': 0.11227830832196453, 'fraction_numerical': 0.0035470668485675307, 'mean_word_length': 4.795256916996047, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 28, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2026394', 'n_tokens_mistral': 2249, 'n_tokens_neox': 2187, 'n_words': 653}