Skip to content

Commit 8579436

Browse files
update README and add docs
1 parent 45c9f14 commit 8579436

File tree

7 files changed

+170
-122
lines changed

7 files changed

+170
-122
lines changed

README.md

Lines changed: 8 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,138 +1,24 @@
1-
[js-permutation](http://aureooms.github.io/js-permutation)
1+
[@aureooms/js-permutation](https://aureooms.github.io/js-permutation)
22
==
33

4-
Permutations code bricks for JavaScript.
4+
<img src="https://upload.wikimedia.org/wikipedia/commons/e/e0/Symmetric_group_3;_Cayley_table;_matrices.svg" width="864">
5+
6+
Permutation library for JavaScript.
7+
See [docs](https://aureooms.github.io/js-permutation).
8+
Parent is [@aureooms/js-algorithms](https://github.com/aureooms/js-algorithms).
59

610
```js
11+
import { next , reversed , identity } from '@aureooms/js-permutation' ;
712
next( reversed( identity( 3 ) ) ) ; // [ 0 , 1 , 2 ]
813
```
914

1015
[![License](https://img.shields.io/github/license/aureooms/js-permutation.svg?style=flat)](https://raw.githubusercontent.com/aureooms/js-permutation/master/LICENSE)
1116
[![NPM version](https://img.shields.io/npm/v/@aureooms/js-permutation.svg?style=flat)](https://www.npmjs.org/package/@aureooms/js-permutation)
12-
[![Bower version](https://img.shields.io/bower/v/@aureooms/js-permutation.svg?style=flat)](http://bower.io/search/?q=@aureooms/js-permutation)
1317
[![Build Status](https://img.shields.io/travis/aureooms/js-permutation.svg?style=flat)](https://travis-ci.org/aureooms/js-permutation)
1418
[![Coverage Status](https://img.shields.io/coveralls/aureooms/js-permutation.svg?style=flat)](https://coveralls.io/r/aureooms/js-permutation)
1519
[![Dependencies Status](https://img.shields.io/david/aureooms/js-permutation.svg?style=flat)](https://david-dm.org/aureooms/js-permutation#info=dependencies)
1620
[![devDependencies Status](https://img.shields.io/david/dev/aureooms/js-permutation.svg?style=flat)](https://david-dm.org/aureooms/js-permutation#info=devDependencies)
1721
[![Code Climate](https://img.shields.io/codeclimate/github/aureooms/js-permutation.svg?style=flat)](https://codeclimate.com/github/aureooms/js-permutation)
1822
[![NPM downloads per month](https://img.shields.io/npm/dm/@aureooms/js-permutation.svg?style=flat)](https://www.npmjs.org/package/@aureooms/js-permutation)
1923
[![GitHub issues](https://img.shields.io/github/issues/aureooms/js-permutation.svg?style=flat)](https://github.com/aureooms/js-permutation/issues)
20-
[![Inline docs](http://inch-ci.org/github/aureooms/js-permutation.svg?branch=master&style=shields)](http://inch-ci.org/github/aureooms/js-permutation)
21-
22-
Can be managed through [jspm](https://github.com/jspm/jspm-cli),
23-
[duo](https://github.com/duojs/duo),
24-
[component](https://github.com/componentjs/component),
25-
[bower](https://github.com/bower/bower),
26-
[ender](https://github.com/ender-js/Ender),
27-
[jam](https://github.com/caolan/jam),
28-
[spm](https://github.com/spmjs/spm),
29-
and [npm](https://github.com/npm/npm).
30-
31-
## Caveat
32-
33-
Requires `regeneratorRuntime` to be defined, see
34-
[babel docs](http://babeljs.io/docs/usage/polyfill/).
35-
36-
## Install
37-
38-
### jspm
39-
```terminal
40-
jspm install github:aureooms/js-permutation
41-
# or
42-
jspm install npm:@aureooms/js-permutation
43-
```
44-
### duo
45-
No install step needed for duo!
46-
47-
### component
48-
```terminal
49-
component install aureooms/js-permutation
50-
```
51-
52-
### bower
53-
```terminal
54-
bower install @aureooms/js-permutation
55-
```
56-
57-
### ender
58-
```terminal
59-
ender add @aureooms/js-permutation
60-
```
61-
62-
### jam
63-
```terminal
64-
jam install @aureooms/js-permutation
65-
```
66-
67-
### spm
68-
```terminal
69-
spm install @aureooms/js-permutation --save
70-
```
71-
72-
### npm
73-
```terminal
74-
npm install @aureooms/js-permutation --save
75-
```
76-
77-
## Require
78-
### jspm
79-
```js
80-
let permutation = require( "github:aureooms/js-permutation" ) ;
81-
// or
82-
import permutation from '@aureooms/js-permutation' ;
83-
```
84-
### duo
85-
```js
86-
let permutation = require( "aureooms/js-permutation" ) ;
87-
```
88-
89-
### component, ender, spm, npm
90-
```js
91-
let permutation = require( "@aureooms/js-permutation" ) ;
92-
```
93-
94-
### bower
95-
The script tag exposes the global variable `permutation`.
96-
```html
97-
<script src="bower_components/@aureooms/js-permutation/js/dist/permutation.min.js"></script>
98-
```
99-
Alternatively, you can use any tool mentioned [here](http://bower.io/docs/tools/).
100-
101-
### jam
102-
```js
103-
require( [ "@aureooms/js-permutation" ] , function ( permutation ) { ... } ) ;
104-
```
105-
106-
## Use
107-
108-
```js
109-
let sigma = permutation.identity( 3 ) ;
110-
111-
sigma ; // [ 0 , 1 , 2 ]
112-
113-
permutation.reversed( sigma ) ; // [ 2 , 1 , 0 ]
114-
115-
permutation.next( sigma ) ; // [ 0 , 2 , 1 ]
116-
117-
for ( let tau of permutation.permutations( 3 ) ) {
118-
119-
... // yields [ 0 , 1 , 2 ]
120-
// [ 0 , 2 , 1 ]
121-
// [ 1 , 0 , 2 ]
122-
// [ 1 , 2 , 0 ]
123-
// [ 2 , 0 , 1 ]
124-
// [ 2 , 1 , 0 ]
125-
126-
}
127-
128-
permutation.invert( [ 0 , 1 , 2 ] ) ; // [ 0 , 1 , 2 ]
129-
permutation.invert( [ 0 , 2 , 1 ] ) ; // [ 0 , 2 , 1 ]
130-
permutation.invert( [ 1 , 0 , 2 ] ) ; // [ 1 , 0 , 2 ]
131-
permutation.invert( [ 1 , 2 , 0 ] ) ; // [ 2 , 0 , 1 ]
132-
permutation.invert( [ 2 , 0 , 1 ] ) ; // [ 1 , 2 , 0 ]
133-
permutation.invert( [ 2 , 1 , 0 ] ) ; // [ 2 , 1 , 0 ]
134-
135-
permutation.compose( "abc" , [ 2 , 0 , 1 ] ) ; // [ "c" , "a" , "b" ]
136-
137-
permutation.bitreversal( 8 ) ; // [ 0 , 4 , 2 , 6 , 1 , 5 , 3 , 7 ]
138-
```
24+
[![Documentation](https://aureooms.github.io/js-permutation/badge.svg)](https://aureooms.github.io/js-permutation/source.html)

doc/css/style.css

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
h1,
2+
h2,
3+
.navigation,
4+
.layout-container > header,
5+
footer
6+
{
7+
border: none;
8+
}
9+
10+
.project-name {
11+
color: #FC913A;
12+
font-weight: bold;
13+
}
14+
15+
.layout-container > header > a.repo-url-github {
16+
font-size: inherit;
17+
display: inline;
18+
background: none;
19+
vertical-align: inherit;
20+
}
21+
22+
.search-box img {
23+
display: none;
24+
}
25+
26+
.search-box::before{
27+
content: "search";
28+
}
29+
30+
.search-input-edge {
31+
height: 0px;
32+
}
33+
34+
.search-result {
35+
width: 300px;
36+
margin-left: 42px;
37+
box-shadow: 1px 1px 13px rgba(0,0,0,0.2);
38+
}
39+
40+
.search-input {
41+
visibility: visible;
42+
}
43+
44+
.search-result li.search-separator {
45+
text-transform: capitalize;
46+
background-color: #ccc;
47+
}
48+
49+
span[data-ice="signature"] > span {
50+
/*font-weight: bold;*/
51+
font-style: italic;
52+
}

doc/manual/example.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
```js
2+
import {
3+
identity ,
4+
reversed ,
5+
next
6+
} from '@aureooms/js-permutation' ;
7+
8+
let sigma = identity( 3 ) ;
9+
10+
sigma ; // [ 0 , 1 , 2 ]
11+
12+
reversed( sigma ) ; // [ 2 , 1 , 0 ]
13+
14+
next( sigma ) ; // [ 0 , 2 , 1 ]
15+
16+
17+
import { permutations } from '@aureooms/js-permutation' ;
18+
19+
for ( let tau of permutations( 3 ) ) {
20+
21+
... // yields [ 0 , 1 , 2 ]
22+
// [ 0 , 2 , 1 ]
23+
// [ 1 , 0 , 2 ]
24+
// [ 1 , 2 , 0 ]
25+
// [ 2 , 0 , 1 ]
26+
// [ 2 , 1 , 0 ]
27+
28+
}
29+
30+
31+
import { invert } from '@aureooms/js-permutation' ;
32+
33+
invert( [ 0 , 1 , 2 ] ) ; // [ 0 , 1 , 2 ]
34+
invert( [ 0 , 2 , 1 ] ) ; // [ 0 , 2 , 1 ]
35+
invert( [ 1 , 0 , 2 ] ) ; // [ 1 , 0 , 2 ]
36+
invert( [ 1 , 2 , 0 ] ) ; // [ 2 , 0 , 1 ]
37+
invert( [ 2 , 0 , 1 ] ) ; // [ 1 , 2 , 0 ]
38+
invert( [ 2 , 1 , 0 ] ) ; // [ 2 , 1 , 0 ]
39+
40+
41+
import { compose } from '@aureooms/js-permutation' ;
42+
43+
compose( "abc" , [ 2 , 0 , 1 ] ) ; // [ "c" , "a" , "b" ]
44+
45+
46+
import { bitreversal } from '@aureooms/js-permutation' ;
47+
48+
bitreversal( 8 ) ; // [ 0 , 4 , 2 , 6 , 1 , 5 , 3 , 7 ]
49+
```

doc/manual/installation.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Can be managed using
2+
[jspm](http://jspm.io)
3+
or [npm](https://github.com/npm/npm).
4+
5+
### jspm
6+
```terminal
7+
jspm install npm:@aureooms/js-permutation
8+
```
9+
10+
### npm
11+
```terminal
12+
npm install @aureooms/js-permutation --save
13+
```

doc/manual/overview.md

Whitespace-only changes.

doc/manual/usage.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
The code needs a ES2015+ polyfill to work, for example
2+
[babel-polyfill](https://babeljs.io/docs/usage/polyfill).
3+
```js
4+
require( 'babel-polyfill' ) ;
5+
// or
6+
import 'babel-polyfill' ;
7+
```
8+
9+
Then
10+
```js
11+
const permutation = require( '@aureooms/js-permutation' ) ;
12+
// or
13+
import * as permutation from '@aureooms/js-permutation' ;
14+
```

doc/scripts/header.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
var domReady = function(callback) {
2+
var state = document.readyState ;
3+
if ( state === 'interactive' || state === 'complete' ) {
4+
callback() ;
5+
}
6+
else {
7+
document.addEventListener('DOMContentLoaded', callback);
8+
}
9+
} ;
10+
11+
12+
domReady(function(){
13+
14+
var projectname = document.createElement('a');
15+
projectname.classList.add('project-name');
16+
projectname.text = 'aureooms/js-permutation';
17+
projectname.href = './index.html' ;
18+
19+
var header = document.getElementsByTagName('header')[0] ;
20+
header.insertBefore(projectname,header.firstChild);
21+
22+
var testlink = document.querySelector('header > a[data-ice="testLink"]') ;
23+
testlink.href = 'https://coveralls.io/github/aureooms/js-permutation' ;
24+
testlink.target = '_BLANK' ;
25+
26+
var searchBox = document.querySelector('.search-box');
27+
var input = document.querySelector('.search-input');
28+
29+
// active search box when focus on searchBox.
30+
input.addEventListener('focus', function(){
31+
searchBox.classList.add('active');
32+
});
33+
34+
});

0 commit comments

Comments
 (0)