-
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 f91a14d
Showing
19 changed files
with
367 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,9 @@ | ||
node_modules | ||
bower_components | ||
coverage | ||
npm-debug.log | ||
yarn.lock | ||
package-lock.json | ||
.DS_Store | ||
.idea | ||
.vscode |
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,8 @@ | ||
.idea | ||
.DS_Store | ||
**/npm-debug.log | ||
**/node_modules | ||
test | ||
src | ||
build | ||
gulpfile.js |
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": 80, | ||
"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,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,15 @@ | ||
# next-is-promise | ||
> Test whether an object looks like a promisesA+ promise | ||
## installation | ||
```bash | ||
npm install -S afeiship/next-is-promise --registry=https://registry.npm.taobao.org | ||
``` | ||
|
||
## usage | ||
```js | ||
//DOCS here! | ||
``` | ||
|
||
## resources | ||
- https://github.com/then/is-promise |
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,28 @@ | ||
{ | ||
"name": "next-is-promise", | ||
"version": "0.0.1", | ||
"description": "Test whether an object looks like a promisesA+ promise", | ||
"main": "dist/next-is-promise.js", | ||
"authors": [ | ||
"afei" | ||
], | ||
"license": "MIT", | ||
"keywords": [ | ||
"next" | ||
], | ||
"homepage": "https://github.com/afeiship/next-is-promise", | ||
"moduleType": [ | ||
"amd" | ||
], | ||
"ignore": [ | ||
"**/.*", | ||
"node_modules", | ||
"bower_components", | ||
"test", | ||
"tests", | ||
"build", | ||
"src", | ||
"gulp", | ||
"gulpfile.js" | ||
] | ||
} |
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 @@ | ||
(function() { | ||
'use strict'; | ||
|
||
const gulp = require('gulp'); | ||
const config = require('./config'); | ||
const $ = require('gulp-load-plugins')({ | ||
pattern: ['gulp-*', 'gulp.*', 'del'] | ||
}); | ||
|
||
//clean | ||
gulp.task( | ||
'clean', | ||
gulp.parallel(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,29 @@ | ||
(function() { | ||
'use strict'; | ||
|
||
const rootPath = process.cwd(); | ||
const gulp = require('gulp'); | ||
const saveLicense = require('uglify-save-license'); | ||
|
||
module.exports = { | ||
path: { | ||
root: rootPath, | ||
src: rootPath + '/src', | ||
dist: rootPath + '/dist', | ||
gulp: rootPath + '/gulp' | ||
}, | ||
sassOptions: { | ||
normal: { | ||
outputStyle: 'expanded' /* nested | expanded | compact | compressed */ | ||
}, | ||
minify: { | ||
outputStyle: 'compressed' | ||
} | ||
}, | ||
uglifyOptions: { | ||
output: { | ||
comments: saveLicense | ||
} | ||
} | ||
}; | ||
})(); |
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,38 @@ | ||
(function() { | ||
'use strict'; | ||
|
||
const gulp = require('gulp'); | ||
const config = require('./config'); | ||
const pkg = require('../package.json'); | ||
const saveLicense = require('uglify-save-license'); | ||
const $ = require('gulp-load-plugins')({ | ||
pattern: ['gulp-*', 'gulp.*', 'del'] | ||
}); | ||
|
||
require('next-nice-comments'); | ||
|
||
const niceComments = nx.niceComments( | ||
[ | ||
'name: <%= pkg.name %>', | ||
'url: <%= pkg.homepage %>', | ||
'version: <%= pkg.version %>', | ||
'license: <%= pkg.license %>' | ||
], | ||
'js' | ||
); | ||
|
||
gulp.task( | ||
'scripts', | ||
gulp.parallel(function() { | ||
return gulp | ||
.src('src/*.js') | ||
.pipe($.header(niceComments, { pkg: pkg })) | ||
.pipe(gulp.dest('dist')) | ||
.pipe($.size({ title: '[ default size ]:' })) | ||
.pipe($.uglify(config.uglifyOptions)) | ||
.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,23 @@ | ||
(function() { | ||
'use strict'; | ||
|
||
var gulp = require('gulp'); | ||
var $ = require('gulp-load-plugins')({ | ||
pattern: ['gulp-*', 'gulp.*', 'del'] | ||
}); | ||
|
||
/** | ||
* @thanks to: | ||
* http://www.jianshu.com/p/d616d3bf391f | ||
*/ | ||
|
||
gulp.task( | ||
'bump', | ||
gulp.parallel(function() { | ||
gulp | ||
.src(['./*.json']) | ||
.pipe($.bump()) | ||
.pipe(gulp.dest('./')); | ||
}) | ||
); | ||
})(); |
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 @@ | ||
/*! | ||
* name: next-is-promise | ||
* url: https://github.com/afeiship/next-is-promise | ||
* version: 1.0.0 | ||
* license: MIT | ||
*/ | ||
|
||
(function() { | ||
var global = global || this || window || Function('return this')(); | ||
var nx = global.nx || require('next-js-core2'); | ||
var OBJ = 'object'; | ||
var FUNC = 'function'; | ||
|
||
nx.isPromise = function(inObj) { | ||
return ( | ||
!!inObj && | ||
(typeof inObj === OBJ || typeof inObj === FUNC) && | ||
typeof obj.then === FUNC | ||
); | ||
}; | ||
|
||
if (typeof module !== 'undefined' && module.exports) { | ||
module.exports = nx.isPromise; | ||
} | ||
})(); |
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,7 @@ | ||
/*! | ||
* name: next-is-promise | ||
* url: https://github.com/afeiship/next-is-promise | ||
* version: 1.0.0 | ||
* license: MIT | ||
*/ | ||
!function(){var e=e||this||window||Function("return this")(),o=e.nx||require("next-js-core2");o.isPromise=function(e){return!!e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof obj.then},"undefined"!=typeof module&&module.exports&&(module.exports=o.isPromise)}(); |
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,36 @@ | ||
{ | ||
"name": "next-is-promise", | ||
"version": "1.0.0", | ||
"description": "Test whether an object looks like a promisesA+ promise", | ||
"homepage": "https://github.com/afeiship/next-is-promise", | ||
"author": { | ||
"name": "afei", | ||
"email": "1290657123@qq.com" | ||
}, | ||
"scripts": { | ||
"build": "gulp", | ||
"test": "jest", | ||
"version": "gulp bump" | ||
}, | ||
"main": "dist/next-is-promise.js", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"del": "^2.2.1", | ||
"gulp": "^4.0.2", | ||
"gulp-bump": "^3.1.3", | ||
"gulp-concat": "^2.6.0", | ||
"gulp-header": "^2.0.7", | ||
"gulp-load-plugins": "^1.2.0", | ||
"gulp-rename": "^1.2.2", | ||
"gulp-size": "^2.1.0", | ||
"gulp-uglify": "^2.1.2", | ||
"jest": "^23.6.0", | ||
"yargs": "^4.7.1", | ||
"uglify-save-license": "^0.4.1", | ||
"prettier": "^1.14.3", | ||
"next-nice-comments": "github:afeiship/next-nice-comments" | ||
}, | ||
"dependencies": { | ||
"next-js-core2": "github:afeiship/next-js-core2" | ||
} | ||
} |
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 = global || this || window || Function('return this')(); | ||
var nx = global.nx || require('next-js-core2'); | ||
var OBJ = 'object'; | ||
var FUNC = 'function'; | ||
|
||
nx.isPromise = function(inObj) { | ||
return ( | ||
!!inObj && | ||
(typeof inObj === OBJ || typeof inObj === FUNC) && | ||
typeof obj.then === FUNC | ||
); | ||
}; | ||
|
||
if (typeof module !== 'undefined' && module.exports) { | ||
module.exports = nx.isPromise; | ||
} | ||
})(); |
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,16 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>Document</title> | ||
<script src="../node_modules/next-js-core2/dist/next-js-core2.js"></script> | ||
<script src="../src/next-is-promise.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
//YOUR CODES | ||
</script> | ||
</body> | ||
</html> |
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,15 @@ | ||
var nx = require('next-js-core2'); | ||
require('../src/next-is-promise'); | ||
|
||
|
||
test('nx.isPromise', function () { | ||
var obj1 = {name: 'fei'}; | ||
var obj2 = {email: '1290657123@qq.com'}; | ||
|
||
var result = {}; | ||
|
||
nx.isPromise(result, obj1, obj2); | ||
|
||
expect(result.name, obj1.name).toBe(null); | ||
}); | ||
|