Skip to content

Commit bbde38c

Browse files
committed
init
0 parents  commit bbde38c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+3580
-0
lines changed

.gitignore

+170
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
### https://raw.github.com/github/gitignore/608690d6b9a78c2a003affc792e49a84905b3118/Node.gitignore
2+
3+
# Logs
4+
logs
5+
*.log
6+
7+
# Runtime data
8+
pids
9+
*.pid
10+
*.seed
11+
12+
# Directory for instrumented libs generated by jscoverage/JSCover
13+
lib-cov
14+
15+
# Coverage directory used by tools like istanbul
16+
coverage
17+
18+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
19+
.grunt
20+
21+
# node-waf configuration
22+
.lock-wscript
23+
24+
# Compiled binary addons (http://nodejs.org/api/addons.html)
25+
build/Release
26+
27+
# Dependency directory
28+
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
29+
node_modules
30+
31+
# Debug log from npm
32+
npm-debug.log
33+
34+
35+
### https://raw.github.com/github/gitignore/608690d6b9a78c2a003affc792e49a84905b3118/Global/JetBrains.gitignore
36+
37+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
38+
39+
*.iml
40+
41+
## Directory-based project format:
42+
.idea/
43+
# if you remove the above rule, at least ignore the following:
44+
45+
# User-specific stuff:
46+
# .idea/workspace.xml
47+
# .idea/tasks.xml
48+
# .idea/dictionaries
49+
50+
# Sensitive or high-churn files:
51+
# .idea/dataSources.ids
52+
# .idea/dataSources.xml
53+
# .idea/sqlDataSources.xml
54+
# .idea/dynamic.xml
55+
# .idea/uiDesigner.xml
56+
57+
# Gradle:
58+
# .idea/gradle.xml
59+
# .idea/libraries
60+
61+
# Mongo Explorer plugin:
62+
# .idea/mongoSettings.xml
63+
64+
## File-based project format:
65+
*.ipr
66+
*.iws
67+
68+
## Plugin-specific files:
69+
70+
# IntelliJ
71+
out/
72+
73+
# mpeltonen/sbt-idea plugin
74+
.idea_modules/
75+
76+
# JIRA plugin
77+
atlassian-ide-plugin.xml
78+
79+
# Crashlytics plugin (for Android Studio and IntelliJ)
80+
com_crashlytics_export_strings.xml
81+
crashlytics.properties
82+
crashlytics-build.properties
83+
84+
85+
/lib
86+
### https://raw.github.com/github/gitignore/608690d6b9a78c2a003affc792e49a84905b3118/Node.gitignore
87+
88+
# Logs
89+
logs
90+
*.log
91+
92+
# Runtime data
93+
pids
94+
*.pid
95+
*.seed
96+
97+
# Directory for instrumented libs generated by jscoverage/JSCover
98+
lib-cov
99+
100+
# Coverage directory used by tools like istanbul
101+
coverage
102+
103+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
104+
.grunt
105+
106+
# node-waf configuration
107+
.lock-wscript
108+
109+
# Compiled binary addons (http://nodejs.org/api/addons.html)
110+
build/Release
111+
112+
# Dependency directory
113+
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
114+
node_modules
115+
116+
# Debug log from npm
117+
npm-debug.log
118+
119+
120+
### https://raw.github.com/github/gitignore/608690d6b9a78c2a003affc792e49a84905b3118/Global/JetBrains.gitignore
121+
122+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
123+
124+
*.iml
125+
126+
## Directory-based project format:
127+
.idea/
128+
# if you remove the above rule, at least ignore the following:
129+
130+
# User-specific stuff:
131+
# .idea/workspace.xml
132+
# .idea/tasks.xml
133+
# .idea/dictionaries
134+
135+
# Sensitive or high-churn files:
136+
# .idea/dataSources.ids
137+
# .idea/dataSources.xml
138+
# .idea/sqlDataSources.xml
139+
# .idea/dynamic.xml
140+
# .idea/uiDesigner.xml
141+
142+
# Gradle:
143+
# .idea/gradle.xml
144+
# .idea/libraries
145+
146+
# Mongo Explorer plugin:
147+
# .idea/mongoSettings.xml
148+
149+
## File-based project format:
150+
*.ipr
151+
*.iws
152+
153+
## Plugin-specific files:
154+
155+
# IntelliJ
156+
out/
157+
158+
# mpeltonen/sbt-idea plugin
159+
.idea_modules/
160+
161+
# JIRA plugin
162+
atlassian-ide-plugin.xml
163+
164+
# Crashlytics plugin (for Android Studio and IntelliJ)
165+
com_crashlytics_export_strings.xml
166+
crashlytics.properties
167+
crashlytics-build.properties
168+
169+
170+
/lib

.travis.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
sudo: false
2+
language: node_js
3+
node_js: "stable"

LICENSE

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2018 azu
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

README.md

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# @textlint/pattern-string-matcher
2+
3+
Regexp-like string matcher library.
4+
5+
## Install
6+
7+
Install with [npm](https://www.npmjs.com/):
8+
9+
npm install @textlint/pattern-string-matcher
10+
11+
## Usage
12+
13+
Interface:
14+
15+
```ts
16+
export interface matchPatternResult {
17+
match: string;
18+
startIndex: number;
19+
endIndex: number;
20+
}
21+
/**
22+
* Match patternStrings and return matchPatternResults
23+
* @param text target text
24+
* @param patternStrings an array of pattern string
25+
*/
26+
export declare const matchPatterns: (text: string, patternStrings: string[]) => matchPatternResult[];
27+
```
28+
29+
Example:
30+
31+
```js
32+
import { matchPatterns } from "@textlint/pattern-string-matcher";
33+
const inputText = `
34+
GitHub is a web-based hosting service for version control using git.
35+
It is mostly used for computer code.
36+
GitHub launched in Apr 10, 2008.
37+
`;
38+
const inputPatterns = [
39+
"git", // => /git/g
40+
"/github/i", // /github/ig
41+
"/\\d+/" // => /\d/g
42+
];
43+
44+
const results = matchPatterns(inputText, inputPatterns);
45+
assert.deepStrictEqual(results, [
46+
{ match: "GitHub", startIndex: 1, endIndex: 7 },
47+
{ match: "git", startIndex: 65, endIndex: 68 },
48+
{ match: "GitHub", startIndex: 107, endIndex: 113 },
49+
{ match: "10", startIndex: 130, endIndex: 132 },
50+
{ match: "2008", startIndex: 134, endIndex: 138 }
51+
]);
52+
```
53+
54+
## Example patterns
55+
56+
- [ ] Need to more documents
57+
58+
## Changelog
59+
60+
See [Releases page](https://github.com/textlint/pattern-string-matcher/releases).
61+
62+
## Running tests
63+
64+
Install devDependencies and Run `npm test`:
65+
66+
npm i -d && npm test
67+
68+
### How to add snapshot tests?
69+
70+
1. Create new dir to `./snapshots/<name>/`
71+
2. Add `input.txt` and `input-patterns.json`
72+
3. Run `npm run test:updateSnapshot`
73+
4. You should verify the output results manually
74+
5. Run `npm test` and pass it
75+
5. Commit it
76+
77+
## Contributing
78+
79+
Pull requests and stars are always welcome.
80+
81+
For bugs and feature requests, [please create an issue](https://github.com/textlint/pattern-string-matcher/issues).
82+
83+
1. Fork it!
84+
2. Create your feature branch: `git checkout -b my-new-feature`
85+
3. Commit your changes: `git commit -am 'Add some feature'`
86+
4. Push to the branch: `git push origin my-new-feature`
87+
5. Submit a pull request :D
88+
89+
## Author
90+
91+
- [github/azu](https://github.com/azu)
92+
- [twitter/azu_re](https://twitter.com/azu_re)
93+
94+
## License
95+
96+
MIT © azu

package.json

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"name": "@textlint/pattern-string-matcher",
3+
"version": "1.0.0",
4+
"description": "Regexp-like string matcher.",
5+
"keywords": [
6+
"helper",
7+
"regexp",
8+
"util"
9+
],
10+
"homepage": "https://github.com/textlint/pattern-string-matcher",
11+
"bugs": {
12+
"url": "https://github.com/textlint/pattern-string-matcher/issues"
13+
},
14+
"license": "MIT",
15+
"author": "azu",
16+
"files": [
17+
"bin/",
18+
"lib/",
19+
"src/"
20+
],
21+
"main": "lib/pattern-string-matcher.js",
22+
"types": "lib/pattern-string-matcher.d.ts",
23+
"directories": {
24+
"lib": "lib",
25+
"test": "test"
26+
},
27+
"repository": {
28+
"type": "git",
29+
"url": "https://github.com/textlint/pattern-string-matcher.git"
30+
},
31+
"scripts": {
32+
"build": "cross-env NODE_ENV=production tsc -p .",
33+
"precommit": "lint-staged",
34+
"postcommit": "git reset",
35+
"prepublish": "npm run --if-present build",
36+
"test:updateSnapshot": "cross-env UPDATE_SNAPSHOT=1 npm test",
37+
"test": "mocha \"test/**/*.ts\"",
38+
"prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"",
39+
"watch": "tsc -p . --watch"
40+
},
41+
"prettier": {
42+
"printWidth": 120,
43+
"singleQuote": false,
44+
"tabWidth": 4
45+
},
46+
"devDependencies": {
47+
"@types/lodash.sortby": "^4.7.3",
48+
"@types/lodash.uniq": "^4.5.3",
49+
"@types/lodash.uniqwith": "^4.5.3",
50+
"@types/mocha": "^5.2.0",
51+
"@types/node": "^10.1.2",
52+
"cross-env": "^5.1.5",
53+
"husky": "^0.14.3",
54+
"lint-staged": "^7.1.2",
55+
"mocha": "^5.2.0",
56+
"prettier": "^1.12.1",
57+
"ts-node": "^6.0.3",
58+
"ts-node-test-register": "^3.0.0",
59+
"typescript": "^2.8.3"
60+
},
61+
"publishConfig": {
62+
"access": "public"
63+
},
64+
"lint-staged": {
65+
"*.{js,jsx,ts,tsx,css}": [
66+
"prettier --write",
67+
"git add"
68+
]
69+
},
70+
"dependencies": {
71+
"execall": "^1.0.0",
72+
"lodash.sortby": "^4.7.0",
73+
"lodash.uniq": "^4.5.0",
74+
"lodash.uniqwith": "^4.5.0",
75+
"to-regex": "^3.0.2"
76+
}
77+
}

0 commit comments

Comments
 (0)