Skip to content

Commit

Permalink
📚 docs: Fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
make-github-pseudonymous-again committed Apr 27, 2020
1 parent 060c808 commit 730058a
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 183 deletions.
148 changes: 3 additions & 145 deletions README.md
@@ -1,7 +1,8 @@
[js-compare](http://aureooms.github.io/js-compare)
[@aureooms/js-compare](http://aureooms.github.io/js-compare)
==

Comparison code bricks for JavaScript.
Comparison library for JavaScript.
See [docs](https://aureooms.github.io/js-compare/index.html).

```js
let compare = reverse( lexicographical( increasing ) ) ;
Expand All @@ -23,149 +24,6 @@ compare( [ 1 , 1 ] , [ 1 , 2 ] ) > 0 ; // true
[![Documentation](http://aureooms.github.io/js-compare//badge.svg)](http://aureooms.github.io/js-compare//source.html)
[![Package size](https://img.shields.io/bundlephobia/minzip/@aureooms/js-compare)](https://bundlephobia.com/result?p=@aureooms/js-compare)

Can be managed through [jspm](https://github.com/jspm/jspm-cli),
[duo](https://github.com/duojs/duo),
[component](https://github.com/componentjs/component),
[bower](https://github.com/bower/bower),
[ender](https://github.com/ender-js/Ender),
[jam](https://github.com/caolan/jam),
[spm](https://github.com/spmjs/spm),
and [npm](https://github.com/npm/npm).

## Install

### jspm
```terminal
jspm install github:aureooms/js-compare
# or
jspm install npm:@aureooms/js-compare
```
### duo
No install step needed for duo!

### component
```terminal
component install aureooms/js-compare
```

### bower
```terminal
bower install @aureooms/js-compare
```

### ender
```terminal
ender add @aureooms/js-compare
```

### jam
```terminal
jam install @aureooms/js-compare
```

### spm
```terminal
spm install @aureooms/js-compare --save
```

### npm
```terminal
npm install @aureooms/js-compare --save
```

## Require
### jspm
```js
let compare = require( "github:aureooms/js-compare" ) ;
// or
import compare from '@aureooms/js-compare' ;
```
### duo
```js
let compare = require( "aureooms/js-compare" ) ;
```

### component, ender, spm, npm
```js
let compare = require( "@aureooms/js-compare" ) ;
```

### bower
The script tag exposes the global variable `compare`.
```html
<script src="bower_components/@aureooms/js-compare/js/dist/compare.min.js"></script>
```
Alternatively, you can use any tool mentioned [here](http://bower.io/docs/tools/).

### jam
```js
require( [ "@aureooms/js-compare" ] , function ( compare ) { ... } ) ;
```

## Use

```js
let increasing = compare.increasing ;
let decreasing = compare.decreasing ;

increasing( 1 , 1 ) === 0 ; // true
increasing( 1 , 2 ) < 0 ; // true
increasing( 2 , 1 ) > 0 ; // true
decreasing( 1 , 1 ) === 0 ; // true
decreasing( 1 , 2 ) > 0 ; // true
decreasing( 2 , 1 ) < 0 ; // true

let lexicographical = compare.lexicographical( increasing ) ;

lexicographical( [ 1 , 1 ] , [ 1 , 1 ] ) === 0 ; // true
lexicographical( [ 1 , 1 ] , [ 1 , 2 ] ) < 0 ; // true
lexicographical( [ 1 , 2 ] , [ 1 , 1 ] ) > 0 ; // true

lexicographical( [ 1 , 1 ] , [ 1 , 1 , 1 ] ) < 0 ; // true
lexicographical( [ 1 , 1 , 1 ] , [ 1 , 1 ] ) > 0 ; // true
lexicographical( [ 2 , 1 ] , [ 1 , 1 , 1 ] ) > 0 ; // true
lexicographical( [ 1 , 1 , 1 ] , [ 2 , 1 ] ) < 0 ; // true

let reverselexicographical = compare.reverse( lexicographical ) ;

reverselexicographical( [ 1 , 1 ] , [ 1 , 1 ] ) === 0 ; // true
reverselexicographical( [ 1 , 1 ] , [ 1 , 2 ] ) > 0 ; // true
reverselexicographical( [ 1 , 2 ] , [ 1 , 1 ] ) < 0 ; // true

reverselexicographical( [ 1 , 1 ] , [ 1 , 1 , 1 ] ) > 0 ; // true
reverselexicographical( [ 1 , 1 , 1 ] , [ 1 , 1 ] ) < 0 ; // true
reverselexicographical( [ 2 , 1 ] , [ 1 , 1 , 1 ] ) < 0 ; // true
reverselexicographical( [ 1 , 1 , 1 ] , [ 2 , 1 ] ) > 0 ; // true

// ... and many more variants.

/** compare backwards, if identical compare length */
let increasing = compare.colexicographical( compare.increasing ) ;
/** compare length first, if identical compare forwards */
let increasing = compare.quasilexicographical( compare.increasing ) ;
/** compare length first, if identical compare backwards */
let increasing = compare.quasicolexicographical( compare.increasing ) ;
/** compare components in range [0, 3[, forwards */
let increasing = compare.fixedlexicographical( compare.increasing , 3 ) ;
/** compare components in range [0, 3[, backwards */
let increasing = compare.fixedcolexicographical( compare.increasing , 3 ) ;
/** compare components in range [1, 4[, forwards */
let increasing = compare.rangedlexicographical( compare.increasing , 1 , 4 ) ;
/** compare components in range [1, 4[, backwards */
let increasing = compare.rangedcolexicographical( compare.increasing , 1 , 4 ) ;

// Also includes comparison function creation tools. Hereunder, all versions are equivalent.
let operator = require( "@aureooms/js-operator" ) ;
let increasing = compare.fn( compare.increasing , operator.len ) ;
let increasing = compare.attr( compare.increasing , "length" ) ;
let increasing = compare.len( compare.increasing ) ;

// Plus an additional useful tool.
compare.sign( -2378 ) === -1 ; // true
compare.sign( 0 ) === 0 ; // true
compare.sign( 2378 ) === 1 ; // true
```

## References

- https://en.wikipedia.org/wiki/Lexicographical_order
40 changes: 20 additions & 20 deletions doc/css/style.css
Expand Up @@ -3,50 +3,50 @@ h2,
.navigation,
.layout-container > header,
footer
{{
{
border: none;
}}
}

.project-name {{
.project-name {
color: #FC913A;
font-weight: bold;
}}
}

.layout-container > header > a.repo-url-github {{
.layout-container > header > a.repo-url-github {
font-size: inherit;
display: inline;
background: none;
vertical-align: inherit;
}}
}

.search-box img {{
.search-box img {
display: none;
}}
}

.search-box::before{{
.search-box::before{
content: "search";
}}
}

.search-input-edge {{
.search-input-edge {
height: 0px;
}}
}

.search-result {{
.search-result {
width: 300px;
margin-left: 42px;
box-shadow: 1px 1px 13px rgba(0,0,0,0.2);
}}
}

.search-input {{
.search-input {
visibility: visible;
}}
}

.search-result li.search-separator {{
.search-result li.search-separator {
text-transform: capitalize;
background-color: #ccc;
}}
}

span[data-ice="signature"] > span {{
span[data-ice="signature"] > span {
/*font-weight: bold;*/
font-style: italic;
}}
}
64 changes: 63 additions & 1 deletion doc/manual/example.md
@@ -1,3 +1,65 @@
# Examples

> More examples in [the test files](https://github.com/{repository}/tree/master/test/src).
> More examples in [the test files](https://github.com/aureooms/js-compare/tree/master/test/src).
```js
let increasing = compare.increasing ;
let decreasing = compare.decreasing ;

increasing( 1 , 1 ) === 0 ; // true
increasing( 1 , 2 ) < 0 ; // true
increasing( 2 , 1 ) > 0 ; // true
decreasing( 1 , 1 ) === 0 ; // true
decreasing( 1 , 2 ) > 0 ; // true
decreasing( 2 , 1 ) < 0 ; // true

let lexicographical = compare.lexicographical( increasing ) ;

lexicographical( [ 1 , 1 ] , [ 1 , 1 ] ) === 0 ; // true
lexicographical( [ 1 , 1 ] , [ 1 , 2 ] ) < 0 ; // true
lexicographical( [ 1 , 2 ] , [ 1 , 1 ] ) > 0 ; // true

lexicographical( [ 1 , 1 ] , [ 1 , 1 , 1 ] ) < 0 ; // true
lexicographical( [ 1 , 1 , 1 ] , [ 1 , 1 ] ) > 0 ; // true
lexicographical( [ 2 , 1 ] , [ 1 , 1 , 1 ] ) > 0 ; // true
lexicographical( [ 1 , 1 , 1 ] , [ 2 , 1 ] ) < 0 ; // true

let reverselexicographical = compare.reverse( lexicographical ) ;

reverselexicographical( [ 1 , 1 ] , [ 1 , 1 ] ) === 0 ; // true
reverselexicographical( [ 1 , 1 ] , [ 1 , 2 ] ) > 0 ; // true
reverselexicographical( [ 1 , 2 ] , [ 1 , 1 ] ) < 0 ; // true

reverselexicographical( [ 1 , 1 ] , [ 1 , 1 , 1 ] ) > 0 ; // true
reverselexicographical( [ 1 , 1 , 1 ] , [ 1 , 1 ] ) < 0 ; // true
reverselexicographical( [ 2 , 1 ] , [ 1 , 1 , 1 ] ) < 0 ; // true
reverselexicographical( [ 1 , 1 , 1 ] , [ 2 , 1 ] ) > 0 ; // true

// ... and many more variants.

/** compare backwards, if identical compare length */
let increasing = compare.colexicographical( compare.increasing ) ;
/** compare length first, if identical compare forwards */
let increasing = compare.quasilexicographical( compare.increasing ) ;
/** compare length first, if identical compare backwards */
let increasing = compare.quasicolexicographical( compare.increasing ) ;
/** compare components in range [0, 3[, forwards */
let increasing = compare.fixedlexicographical( compare.increasing , 3 ) ;
/** compare components in range [0, 3[, backwards */
let increasing = compare.fixedcolexicographical( compare.increasing , 3 ) ;
/** compare components in range [1, 4[, forwards */
let increasing = compare.rangedlexicographical( compare.increasing , 1 , 4 ) ;
/** compare components in range [1, 4[, backwards */
let increasing = compare.rangedcolexicographical( compare.increasing , 1 , 4 ) ;

// Also includes comparison function creation tools. Hereunder, all versions are equivalent.
let operator = require( "@aureooms/js-operator" ) ;
let increasing = compare.fn( compare.increasing , operator.len ) ;
let increasing = compare.attr( compare.increasing , "length" ) ;
let increasing = compare.len( compare.increasing ) ;

// Plus an additional useful tool.
compare.sign( -2378 ) === -1 ; // true
compare.sign( 0 ) === 0 ; // true
compare.sign( 2378 ) === 1 ; // true
```
6 changes: 3 additions & 3 deletions doc/manual/installation.md
Expand Up @@ -8,15 +8,15 @@ or [jspm](https://jspm.org/docs).

### yarn
```terminal
yarn add {fullname}
yarn add @aureooms/js-compare
```

### npm
```terminal
npm install {fullname} --save
npm install @aureooms/js-compare --save
```

### jspm
```terminal
jspm install npm:{fullname}
jspm install npm:@aureooms/js-compare
```
4 changes: 2 additions & 2 deletions doc/manual/usage.md
Expand Up @@ -12,7 +12,7 @@ import '@babel/polyfill' ;

Then, import the library where needed
```js
const {var} = require( '{fullname}' ) ;
const compare = require( '@aureooms/js-compare' ) ;
// or
import * as {var} from '{fullname}' ;
import * as compare from '@aureooms/js-compare' ;
```
24 changes: 12 additions & 12 deletions doc/scripts/header.js
@@ -1,34 +1,34 @@
var domReady = function(callback) {{
var domReady = function(callback) {
var state = document.readyState ;
if ( state === 'interactive' || state === 'complete' ) {{
if ( state === 'interactive' || state === 'complete' ) {
callback() ;
}}
else {{
}
else {
document.addEventListener('DOMContentLoaded', callback);
}}
}} ;
}
} ;


domReady(function(){{
domReady(function(){

var projectname = document.createElement('a');
projectname.classList.add('project-name');
projectname.text = '{repository}';
projectname.text = 'aureooms/js-compare';
projectname.href = './index.html' ;

var header = document.getElementsByTagName('header')[0] ;
header.insertBefore(projectname,header.firstChild);

var testlink = document.querySelector('header > a[data-ice="testLink"]') ;
testlink.href = 'https://coveralls.io/github/{repository}' ;
testlink.href = 'https://coveralls.io/github/aureooms/js-compare' ;
testlink.target = '_BLANK' ;

var searchBox = document.querySelector('.search-box');
var input = document.querySelector('.search-input');

// active search box when focus on searchBox.
input.addEventListener('focus', function(){{
input.addEventListener('focus', function(){
searchBox.classList.add('active');
}});
});

}});
});

0 comments on commit 730058a

Please sign in to comment.