Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobbubu committed Jul 11, 2020
0 parents commit f0f5f61
Show file tree
Hide file tree
Showing 19 changed files with 8,377 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#root = true

[*]
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 100
indent_size = 2

[*.md]
trim_trailing_whitespace = false
2 changes: 2 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Contributing
The repository is released under the MIT license, and follows a standard Github development process, using Github tracker for issues and merging pull requests into master.
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Feature request
about: Suggest an idea for this project

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
14 changes: 14 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
### Type of Change
<!-- What type of change does your code introduce? -->
- [ ] New feature
- [ ] Bug fix
- [ ] Documentation
- [ ] Refactor
- [ ] Chore

### Resolves
- Fixes #[Add issue number here.]

### Describe Changes
<!-- Describe your changes in detail, if applicable. -->
_Describe what this Pull Request does_
17 changes: 17 additions & 0 deletions .github/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Bug report
about: Create a report to help us improve

---

**Describe the bug**
A clear and concise description of what the bug is.

**Workflow**
If applicable, provide a workflow file to help explain your problem.

**Expected behavior**
A clear and concise description of what you expected to happen.

**Additional context**
Add any other context about the problem here.
109 changes: 109 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Build and Release

on:
push:
branches:
- master

jobs:
test:
name: Test on node ${{ matrix.node }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}

strategy:
matrix:
node: [14, 12, 10]
os:
- ubuntu-latest
- windows-latest
- macOS-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Node.JS
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}

- name: Get npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v1
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install
env:
CI: true
run: npm ci

- name: Build
if: success()
run: npm run build

- name: Test
if: success()
run: npm run test:prod

- name: Coveralls
if: success()
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

release:
name: npm publish / GitHub release
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Node.JS
uses: actions/setup-node@v1
with:
node-version: 12

- name: Get npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v1
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install
env:
CI: true
run: npm ci

- name: Build
if: success()
run: npm run build

# npm run test:prod && npm run build && npm run report-coverage
- name: Semantic Release
if: success()
uses: cycjimmy/semantic-release-action@v2
id: semantic
with:
branch: master
extra_plugins: |
@semantic-release/git
@semantic-release/changelog
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: New release published
if: steps.semantic.outputs.new_release_published == 'true'
run: echo ${{ steps.semantic.outputs.new_release_version }}
52 changes: 52 additions & 0 deletions .github/workflows/check-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Check Pull Request

on:
pull_request:
branches:
- master

jobs:
test:
name: Test on node ${{ matrix.node }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}

strategy:
matrix:
node: [14, 12, 10]
os:
- ubuntu-latest
- windows-latest
- macOS-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Node.JS
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}

- name: Get npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v1
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install
env:
CI: true
run: npm ci

- name: Build
if: success()
run: npm run build

- name: Test
if: success()
run: npm run test:prod
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
node_modules
coverage
.nyc_output
.DS_Store
*.log
.vscode
.idea
dist
compiled
.awcache
.rpt2_cache
7 changes: 7 additions & 0 deletions .huskyrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"hooks": {
"pre-commit": "npm run precommit",
"commit-msg": "validate-commit-msg",
"pre-push": "npm run test:prod && npm run build"
}
}
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2017 jacobbubu <rong.shen@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
62 changes: 62 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# @jacobbubu/infer-partial-order

[![Build Status](https://github.com/jacobbubu/infer-partial-order/workflows/Build%20and%20Release/badge.svg)](https://github.com/jacobbubu/infer-partial-order/actions?query=workflow%3A%22Build+and+Release%22)
[![Coverage Status](https://coveralls.io/repos/github/jacobbubu/infer-partial-order/badge.svg)](https://coveralls.io/github/jacobbubu/infer-partial-order)
[![npm](https://img.shields.io/npm/v/@jacobbubu/infer-partial-order.svg)](https://www.npmjs.com/package/@jacobbubu/infer-partial-order/)

> Rewrite [infer-partial-order](https://github.com/dominictarr/infer-partial-order) with TypeScript
# Why rewrite

* Rewriting makes me more aware of the author’s intentions
* Adding a type declaration to the original module will not save much

In order to understand of the function of the module, the following is the original README copied.

# infer-partial-order

infer the partial order of a set from a set of examples.

say we have two sequences `A, B, C` and `B, A, C`.
Here `A < C` and `B < C`, but sometimes `B == A`.
This relationship is obvious, because there are only 3 items,
but as the number of items increase, it's much less clear.

## Example

represent a partial ordering like this:
``` ts
import { infer } from '@jacobbubu/infer-partial-order'

infer([ [A, B, C], [B, A, C] ])

=> {
A:[],
B:[],
C:[A, B]
}
```

Each key maps to the list of items that always come before it.

for more complex cases, you might want to use the canonical mode,
it strips out items that are indirectly lesser than a given item.
This is still enough information to build a graph of the order
relationships.
``` js
var infer = require('infer-partial-order')

infer([ [A, B, C, D, E], [B, A, D, C, E], [A, B, C, D, E])

=> {
A:[],
B:[],
C:[A, B],
D:[A, B],
E:[C, D]
}
```

## License

MIT
Loading

0 comments on commit f0f5f61

Please sign in to comment.