-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4ebdb54
Showing
17 changed files
with
322 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
node_modules | ||
bower_components | ||
coverage | ||
npm-debug.log | ||
yarn.lock | ||
package-lock.json | ||
.DS_Store | ||
.idea | ||
.vscode | ||
|
||
# vscode localhistory | ||
.history |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
.idea | ||
.DS_Store | ||
**/npm-debug.log | ||
**/node_modules | ||
test | ||
__tests__ | ||
src | ||
build | ||
docs | ||
gulpfile.js | ||
|
||
.editorconfig | ||
.prettierrc | ||
Gemfile | ||
jest.config.js | ||
LICENSE.txt | ||
Rakefile | ||
express.js | ||
.vscode | ||
.release-it.json | ||
|
||
|
||
# vscode localhistory | ||
.history | ||
.release-it.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/ | ||
package-lock=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"trailingComma": "none", | ||
"arrowParens": "always", | ||
"printWidth": 100, | ||
"bracketSpacing": true, | ||
"jsxBracketSameLine": true, | ||
"tabWidth": 2, | ||
"semi": true, | ||
"singleQuote": true, | ||
"overrides": [ | ||
{ | ||
"files": "*.scss", | ||
"options": { | ||
"trailingComma": "none", | ||
"tabWidth": 2, | ||
"parser": "scss" | ||
} | ||
}, | ||
{ | ||
"files": "*.json", | ||
"options": { | ||
"trailingComma": "none", | ||
"tabWidth": 2, | ||
"parser": "json" | ||
} | ||
}, | ||
{ | ||
"files": "*.md", | ||
"options": { | ||
"trailingComma": "none", | ||
"tabWidth": 2, | ||
"parser": "json" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"git": { | ||
"requireCleanWorkingDir": false | ||
}, | ||
"hooks": { | ||
"after:init": [ | ||
"npm run test", | ||
"t2k" | ||
], | ||
"after:bump": [ | ||
"npm run build" | ||
] | ||
}, | ||
"github": { | ||
"release": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 afei <1290657123@qq.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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# next-match | ||
> Math groups with next. | ||
[![version][version-image]][version-url] | ||
[![license][license-image]][license-url] | ||
[![size][size-image]][size-url] | ||
[![download][download-image]][download-url] | ||
|
||
## installation | ||
```bash | ||
npm install -S @jswork/next-match | ||
``` | ||
|
||
## usage | ||
```js | ||
import '@jswork/next-match'; | ||
|
||
const str = '/api/v1/{id}/{uuid}/{a.b}'; | ||
|
||
nx.match(str, /{(.*?)}/g, 0); // [ '{id}', '{uuid}', '{a.b}' ] | ||
nx.match(str, /{(.*?)}/g, 1); // ['id', 'uuid', 'a.b'] | ||
``` | ||
|
||
## license | ||
Code released under [the MIT license](https://github.com/afeiship/next-match/blob/master/LICENSE.txt). | ||
|
||
[version-image]: https://img.shields.io/npm/v/@jswork/next-match | ||
[version-url]: https://npmjs.org/package/@jswork/next-match | ||
|
||
[license-image]: https://img.shields.io/npm/l/@jswork/next-match | ||
[license-url]: https://github.com/afeiship/next-match/blob/master/LICENSE.txt | ||
|
||
[size-image]: https://img.shields.io/bundlephobia/minzip/@jswork/next-match | ||
[size-url]: https://github.com/afeiship/next-match/blob/master/dist/next-match.min.js | ||
|
||
[download-image]: https://img.shields.io/npm/dm/@jswork/next-match | ||
[download-url]: https://www.npmjs.com/package/@jswork/next-match |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
(function () { | ||
require('../src'); | ||
|
||
describe('api.basic test', () => { | ||
test('nx.match should match default index 1', function () { | ||
var str = '/api/v1/{id}/{uuid}/{a.b}'; | ||
expect(nx.match(str, /{(.*?)}/g, 0)).toEqual(['{id}', '{uuid}', '{a.b}']); | ||
expect(nx.match(str, /{(.*?)}/g, 1)).toEqual(['id', 'uuid', 'a.b']); | ||
}); | ||
}); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
(function() { | ||
'use strict'; | ||
|
||
const gulp = require('gulp'); | ||
const $ = require('gulp-load-plugins')({ | ||
pattern: ['gulp-*', 'gulp.*', 'del'] | ||
}); | ||
|
||
//clean | ||
gulp.task('clean', function() { | ||
return $.del('dist'); | ||
}); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
(function() { | ||
'use strict'; | ||
|
||
const gulp = require('gulp'); | ||
const saveLicense = require('uglify-save-license'); | ||
const $ = require('gulp-load-plugins')({ | ||
pattern: ['gulp-*', 'gulp.*', 'del', '@jswork/gulp-*'] | ||
}); | ||
|
||
gulp.task('scripts', function() { | ||
return gulp | ||
.src('src/*.js') | ||
.pipe($.jswork.pkgHeader()) | ||
.pipe(gulp.dest('dist')) | ||
.pipe($.size({ title: '[ default size ]:' })) | ||
.pipe($.uglify({ output: { comments: saveLicense } })) | ||
.pipe($.rename({ extname: '.min.js' })) | ||
.pipe(gulp.dest('dist')) | ||
.pipe($.size({ title: '[ minimize size ]:' })); | ||
}); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/*! | ||
* name: @jswork/next-match | ||
* description: Math groups with next. | ||
* homepage: https://github.com/afeiship/next-match | ||
* version: 1.0.0 | ||
* date: 2021-01-13 13:22:59 | ||
* license: MIT | ||
*/ | ||
|
||
(function () { | ||
var global = typeof window !== 'undefined' ? window : this || Function('return this')(); | ||
var nx = global.nx || require('@jswork/next'); | ||
|
||
nx.match = function (inString, inRegExp, inIndex) { | ||
var index = typeof inIndex === 'undefined' ? 1 : inIndex; // default to the first capturing group | ||
var matches = []; | ||
var match; | ||
while ((match = inRegExp.exec(inString))) { | ||
matches.push(match[index]); | ||
} | ||
return matches; | ||
}; | ||
|
||
if (typeof module !== 'undefined' && module.exports) { | ||
module.exports = nx.match; | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/*! | ||
* name: @jswork/next-match | ||
* description: Math groups with next. | ||
* homepage: https://github.com/afeiship/next-match | ||
* version: 1.0.0 | ||
* date: 2021-01-13 13:22:59 | ||
* license: MIT | ||
*/ | ||
!function(){var e=("undefined"!=typeof window?window:this||Function("return this")()).nx||require("@jswork/next");e.match=function(e,n,o){for(var t,r=void 0===o?1:o,u=[];t=n.exec(e);)u.push(t[r]);return u},"undefined"!=typeof module&&module.exports&&(module.exports=e.match)}(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
(function() { | ||
'use strict'; | ||
|
||
const gulp = require('gulp'); | ||
const fs = require('fs'); | ||
|
||
//import | ||
fs.readdirSync('./build').map(function(file) { | ||
require('./build/' + file); | ||
}); | ||
|
||
gulp.task('default', gulp.series(['clean', 'scripts'])); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// https://jestjs.io/docs/en/configuration | ||
module.exports = { | ||
verbose: true, | ||
testRegex: [/\.spec.js/], | ||
//preset: "jest-puppeteer", | ||
moduleNameMapper: { | ||
'^@/(.*)$': '<rootDir>/src/$1' | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"name": "@jswork/next-match", | ||
"version": "1.0.0", | ||
"description": "Math groups with next.", | ||
"homepage": "https://github.com/afeiship/next-match", | ||
"author": { | ||
"name": "afei", | ||
"email": "1290657123@qq.com" | ||
}, | ||
"scripts": { | ||
"build": "gulp", | ||
"test": "jest", | ||
"start": "node ./express.js", | ||
"release": "release-it" | ||
}, | ||
"main": "dist/index.js", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@jswork/gulp-pkg-header": "^1.0.3", | ||
"@jswork/next": "^1.0.3", | ||
"del": "^6.0.0", | ||
"gulp": "^4.0.2", | ||
"gulp-debug": "^4.0.0", | ||
"gulp-header": "^2.0.9", | ||
"gulp-ignore": "^3.0.0", | ||
"gulp-load-plugins": "^2.0.6", | ||
"gulp-rename": "^2.0.0", | ||
"gulp-size": "^3.0.0", | ||
"gulp-uglify": "^3.0.2", | ||
"jest": "^26.6.3", | ||
"prettier": "^2.2.1", | ||
"release-it": "^14.2.2", | ||
"uglify-js": "3.12.1", | ||
"uglify-save-license": "^0.4.1" | ||
}, | ||
"publishConfig": { | ||
"access": "public", | ||
"registry": "https://registry.npmjs.org" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
(function () { | ||
var global = typeof window !== 'undefined' ? window : this || Function('return this')(); | ||
var nx = global.nx || require('@jswork/next'); | ||
|
||
nx.match = function (inString, inRegExp, inIndex) { | ||
var index = typeof inIndex === 'undefined' ? 1 : inIndex; // default to the first capturing group | ||
var matches = []; | ||
var match; | ||
while ((match = inRegExp.exec(inString))) { | ||
matches.push(match[index]); | ||
} | ||
return matches; | ||
}; | ||
|
||
if (typeof module !== 'undefined' && module.exports) { | ||
module.exports = nx.match; | ||
} | ||
})(); |