-
Notifications
You must be signed in to change notification settings - Fork 3
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 e10e2ea
Showing
19 changed files
with
374 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,14 @@ | ||
node_modules | ||
bower_components | ||
coverage | ||
npm-debug.log | ||
yarn.lock | ||
Gemfile.lock | ||
yarn-error.log | ||
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,20 @@ | ||
.idea | ||
.DS_Store | ||
**/npm-debug.log | ||
**/node_modules | ||
test | ||
__tests__ | ||
src | ||
build | ||
gulpfile.js | ||
|
||
.editorconfig | ||
.prettierrc | ||
Gemfile | ||
jest.config.js | ||
LICENSE.txt | ||
Rakefile | ||
.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,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,40 @@ | ||
{ | ||
"trailingComma": "none", | ||
"arrowParens": "always", | ||
"printWidth": 100, | ||
"bracketSpacing": true, | ||
"jsxBracketSameLine": true, | ||
"tabWidth": 2, | ||
"semi": true, | ||
"singleQuote": true, | ||
"overrides": [ | ||
{ | ||
"files": ["*.json", ".eslintrc", ".tslintrc", ".prettierrc", ".tern-project"], | ||
"options": { | ||
"parser": "json", | ||
"tabWidth": 2 | ||
} | ||
}, | ||
{ | ||
"files": "*.{css,sass,scss,less}", | ||
"options": { | ||
"parser": "postcss", | ||
"tabWidth": 2 | ||
} | ||
}, | ||
{ | ||
"files": "*.ts", | ||
"options": { | ||
"parser": "typescript" | ||
} | ||
}, | ||
{ | ||
"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,5 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'fileutils' | ||
gem 'sshkit' | ||
gem 'semver' |
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,29 @@ | ||
# next-object-operator | ||
> Object set/get/sets/gets and other operator. | ||
## installation | ||
```bash | ||
npm install -S @feizheng/next-object-operator | ||
``` | ||
|
||
## apis | ||
| api | params | description | | ||
| ---- | ------------ | --------------------- | | ||
| get | (path) | Get value by path. | | ||
| set | (path,value) | Set value by parh. | | ||
| gets | - | Get the whole object. | | ||
| sets | (object) | Sets multiple values. | | ||
|
||
## usage | ||
```js | ||
import NxObjectOperator from '@feizheng/next-object-operator'; | ||
|
||
const data = {}; | ||
const operator = new NxObjectOperator(data); | ||
|
||
// operators | ||
operator.set | ||
operator.get | ||
operator.sets | ||
operator.gets | ||
``` |
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,4 @@ | ||
|
||
Dir["./node_modules/@feizheng/rake-*/index.rake"].each do |task| | ||
load task | ||
end |
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 @@ | ||
(function () { | ||
var nx = require('@feizheng/next-js-core2'); | ||
var NxObjectOperator = require('../src/next-object-operator'); | ||
|
||
describe('NxObjectOperator', function () { | ||
test('set can change the value', function () { | ||
var data = {}; | ||
var operator = new NxObjectOperator(data); | ||
operator.set('name', 'afei'); | ||
expect(data).toEqual({ name: 'afei' }) | ||
}); | ||
|
||
test('get should get the right value', function () { | ||
var data = {}; | ||
var operator = new NxObjectOperator(data); | ||
operator.set('name', 'afei'); | ||
expect(operator.get('name')).toBe('afei'); | ||
}); | ||
|
||
test('sets can set multiple values', function () { | ||
var data = {}; | ||
var operator = new NxObjectOperator(data); | ||
operator.sets({ name: 'afei', age: 100 }); | ||
expect(data.name).toBe('afei'); | ||
expect(data.age).toBe(100); | ||
}); | ||
|
||
test('gets should return the whole object', function () { | ||
var data = { | ||
name: 'afei', | ||
age: 100 | ||
}; | ||
var operator = new NxObjectOperator(data); | ||
expect(operator.gets()).toEqual({ | ||
name: 'afei', | ||
age: 100 | ||
}); | ||
}); | ||
}); | ||
})(); |
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,24 @@ | ||
(function() { | ||
'use strict'; | ||
|
||
const gulp = require('gulp'); | ||
const saveLicense = require('uglify-save-license'); | ||
const $ = require('gulp-load-plugins')({ | ||
pattern: ['gulp-*', 'gulp.*', 'del', '@feizheng/gulp-*'] | ||
}); | ||
|
||
gulp.task('scripts', function() { | ||
return gulp | ||
.src('src/*.js') | ||
.pipe($.sourcemaps.init()) | ||
.pipe($.feizheng.pkgHeader()) | ||
.pipe($.sourcemaps.write('.')) | ||
.pipe(gulp.dest('dist')) | ||
.pipe($.size({ title: '[ default size ]:' })) | ||
.pipe($.ignore('*.js.map')) | ||
.pipe($.uglify({ output: { comments: saveLicense } })) | ||
.pipe($.rename({ extname: '.min.js' })) | ||
.pipe(gulp.dest('dist')) | ||
.pipe($.size({ title: '[ minimize size ]:' })); | ||
}); | ||
})(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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: @feizheng/next-object-operator | ||
* description: Object set/get/sets/gets and other operator. | ||
* homepage: https://github.com/afeiship/next-object-operator | ||
* version: 1.0.0 | ||
* date: 2020-06-06T03:14:14.905Z | ||
* license: MIT | ||
*/ | ||
!function(){var t=t||this||window||Function("return this")(),n=t.nx||require("@feizheng/next-js-core2"),e=n.declare("nx.ObjectOperator",{methods:{init:function(t){this.data=t},set:function(t,e){n.set(this.data,t,e)},sets:function(t){n.forIn(t,function(t,e){n.set(this.data,t,e)},this)},get:function(t){return n.get(this.data,t)},gets:function(){return this.data}}});"undefined"!=typeof module&&module.exports&&(module.exports=e)}(); |
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": "@feizheng/next-object-operator", | ||
"version": "1.0.0", | ||
"description": "Object set/get/sets/gets and other operator.", | ||
"homepage": "https://github.com/afeiship/next-object-operator", | ||
"author": { | ||
"name": "afei", | ||
"email": "1290657123@qq.com" | ||
}, | ||
"scripts": { | ||
"build": "gulp", | ||
"test": "jest" | ||
}, | ||
"main": "dist/next-object-operator.js", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@feizheng/gulp-pkg-header": "^1.0.4", | ||
"@feizheng/rake-git": "^1.2.1", | ||
"del": "^5.1.0", | ||
"gulp": "^4.0.2", | ||
"gulp-concat": "^2.6.1", | ||
"gulp-debug": "^4.0.0", | ||
"gulp-ignore": "^3.0.0", | ||
"gulp-load-plugins": "^2.0.3", | ||
"gulp-rename": "^2.0.0", | ||
"gulp-size": "^3.0.0", | ||
"gulp-sourcemaps": "^2.6.5", | ||
"gulp-uglify": "^3.0.2", | ||
"jest": "^26.0.1", | ||
"uglify-js": "3.9.4", | ||
"uglify-save-license": "^0.4.1", | ||
"yargs": "^15.3.1" | ||
}, | ||
"dependencies": { | ||
"@feizheng/next-js-core2": "^2.5.0" | ||
}, | ||
"publishConfig": { | ||
"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,34 @@ | ||
(function () { | ||
var global = global || this || window || Function('return this')(); | ||
var nx = global.nx || require('@feizheng/next-js-core2'); | ||
|
||
var NxObjectOperator = nx.declare('nx.ObjectOperator', { | ||
methods: { | ||
init: function (inData) { | ||
this.data = inData; | ||
}, | ||
set: function (inPath, inValue) { | ||
nx.set(this.data, inPath, inValue); | ||
}, | ||
sets: function (inObject) { | ||
nx.forIn( | ||
inObject, | ||
function (key, value) { | ||
nx.set(this.data, key, value); | ||
}, | ||
this | ||
); | ||
}, | ||
get: function (inPath) { | ||
return nx.get(this.data, inPath); | ||
}, | ||
gets: function () { | ||
return this.data; | ||
} | ||
} | ||
}); | ||
|
||
if (typeof module !== 'undefined' && module.exports) { | ||
module.exports = NxObjectOperator; | ||
} | ||
})(); |