-
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
Showing
54 changed files
with
102,592 additions
and
24 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,8 @@ | ||
node_modules | ||
npm-debug.log | ||
.externalToolBuilders | ||
.settings | ||
.project | ||
components | ||
build | ||
sea-modules |
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 @@ | ||
{ | ||
"bitwise": true, | ||
"camelcase": true, | ||
"curly": true, | ||
"eqeqeq": true, | ||
"immed": true, | ||
"latedef": true, | ||
"newcap": true, | ||
"noarg": true, | ||
"noempty": true, | ||
"nonew": true, | ||
"quotmark": true, | ||
"undef": true, | ||
"unused": true, | ||
"node": 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,9 @@ | ||
.* | ||
build | ||
components | ||
dist | ||
node_modules | ||
sea-modules | ||
bower.json | ||
component.json | ||
Makefile |
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,112 @@ | ||
"use strict"; | ||
|
||
module.exports = function(grunt) { | ||
|
||
var matchdep = require("matchdep"); | ||
|
||
// Configuration | ||
grunt.initConfig({ | ||
|
||
pkg: grunt.file.readJSON("package.json"), | ||
|
||
name: "<%= pkg.name %>", | ||
version: "<%= pkg.version %>", | ||
|
||
mainFile: "adam.js", | ||
distFile: "adam.js", | ||
|
||
srcDir: "src", | ||
srcFiles: "**/*.js", | ||
src: "<%= srcDir %>/<%= srcFiles %>", | ||
|
||
destDir: "dist", | ||
|
||
jshint: { | ||
options: { | ||
jshintrc: ".jshintrc" | ||
}, | ||
gruntfile: { | ||
src: "Gruntfile.js" | ||
}, | ||
src: { | ||
src: ["<%= src %>"] | ||
}, | ||
test: { | ||
src: ["test/*.js"] | ||
} | ||
}, | ||
|
||
jsdoc: { | ||
dist: { | ||
src: ["<%= src %>", "README.md"], | ||
options: { | ||
destination: "doc", | ||
template: "node_modules/grunt-jsdoc/node_modules/ink-docstrap/template", | ||
configure: "jsdoc-conf.json" | ||
} | ||
} | ||
}, | ||
|
||
clean: { | ||
dist: { | ||
src: ["<%= destDir %>"] | ||
} | ||
}, | ||
|
||
uglify: { | ||
minify: { | ||
files: [ | ||
{ | ||
expand: true, | ||
cwd: "<%= destDir %>/", | ||
src: "<%= srcFiles %>", | ||
dest: "<%= destDir %>/", | ||
ext: ".min.js" | ||
} | ||
] | ||
} | ||
}, | ||
|
||
umd: { | ||
dist: { | ||
src: "<%= srcDir %>/<%= mainFile %>", | ||
dest: "<%= destDir %>/<%= distFile %>", | ||
template: "unit", | ||
objectToExport: "module.exports", | ||
globalAlias: "<%= name %>", | ||
indent: " " | ||
} | ||
}, | ||
|
||
push: { | ||
options: { | ||
files: ["package.json", "bower.json", "component.json"], | ||
commitMessage: "Release version %VERSION%", | ||
commitFiles: ["-a"], | ||
tagName: "%VERSION%", | ||
tagMessage: "Version %VERSION%" | ||
} | ||
}, | ||
|
||
mochacli: { | ||
all: {} | ||
} | ||
}); | ||
|
||
// Plugins | ||
matchdep.filterDev("grunt-*").forEach(grunt.loadNpmTasks); | ||
|
||
// Tasks | ||
grunt.registerTask("build", ["clean", "umd", "uglify"]); | ||
grunt.registerTask("doc", ["jsdoc"]); | ||
grunt.registerTask("test", ["mochacli"]); | ||
grunt.registerTask("default", ["jshint", "test"]); | ||
grunt.registerTask("all", ["default", "build", "doc"]); | ||
|
||
grunt.registerTask("release", ["push"]); | ||
grunt.registerTask("release-minor", ["push:minor"]); | ||
grunt.registerTask("release-major", ["push:major"]); | ||
|
||
// For Travis CI service | ||
grunt.registerTask("travis", ["all"]); | ||
}; |
Empty file.
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,22 @@ | ||
Copyright (c) 2014 Denis Sikuler | ||
|
||
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 |
---|---|---|
@@ -1,4 +1,129 @@ | ||
adam | ||
==== | ||
# adam | ||
|
||
Functions to create and process objects | ||
Functions to create and process objects. | ||
|
||
[](http://badge.fury.io/js/adam) | ||
[](http://gruntjs.com/) | ||
|
||
## Installation | ||
|
||
### Node | ||
|
||
npm install adam | ||
|
||
### [Component](https://github.com/component/component) | ||
|
||
component install gamtiq/adam | ||
|
||
### [Jam](http://jamjs.org) | ||
|
||
jam install adam | ||
|
||
### [Bower](http://bower.io) | ||
|
||
bower install adam | ||
|
||
### [SPM](http://spmjs.io) | ||
|
||
spm install adam | ||
|
||
### AMD, <script> | ||
|
||
Use `dist/adam.js` or `dist/adam.min.js` (minified version). | ||
|
||
## Usage | ||
|
||
### Node, Component, SPM | ||
|
||
```js | ||
var adam = require("adam"); | ||
``` | ||
|
||
### Jam | ||
|
||
```js | ||
require(["adam"], function(adam) { | ||
... | ||
}); | ||
``` | ||
|
||
### AMD | ||
|
||
```js | ||
define(["path/to/dist/adam.js"], function(adam) { | ||
... | ||
}); | ||
``` | ||
|
||
### Bower, <script> | ||
|
||
```html | ||
|
||
<!-- Use bower_components/adam/dist/adam.js if the library was installed by Bower --> | ||
|
||
<script type="text/javascript" src="path/to/dist/adam.js"></script> | ||
<script type="text/javascript"> | ||
// adam is available via adam field of window object | ||
... | ||
</script> | ||
``` | ||
|
||
### Examples | ||
|
||
```js | ||
var obj = {a: 1, b: 2, c: 3}; | ||
adam.getFreeField({a5: 5, a2: 2, a7: 7, a3: 3}, {prefix: "a", startNum: 2}); // a4 | ||
adam.getSize(obj); // 3 | ||
adam.isSizeMore(obj, 5); // false | ||
adam.getFields(obj); // ["a", "b", "c"] | ||
adam.getValues(obj); // [1, 2, 3] | ||
adam.getValueKey({a: 1, b: 2, c: 3, d: 4}, 3); // c | ||
adam.fromArray([{id: "a", value: 11}, {id: "b", value: 7}, {id: "c", value: 10}], "id"); // {a: {id: "a", value: 11}, b: {id: "b", value: 7}, c: {id: "c", value: 10}} | ||
adam.split({a: 1, b: 2, c: 3, d: 4, e: 5}, ["a", "d"]); // [{a: 1, d: 4}, {b: 2, c: 3, e: 5}] | ||
``` | ||
|
||
## API | ||
|
||
### fromArray(list: Array, [keyField: Function | String], [settings: Object]): Object | ||
|
||
Create object (map) from list of objects. | ||
|
||
### getFields(obj: Object): Array | ||
|
||
Return list of fields of specified object. | ||
|
||
### getFreeField(obj: Object, [settings: Object]): String | ||
|
||
Return name of first free (absent) field of specified object, that conforms to the following pattern: <prefix><number> | ||
|
||
### getSize(obj: Object): Integer | ||
|
||
Return number of fields of specified object. | ||
|
||
### getValueKey(obj: Object, value, [all: Boolean]): Array | String | null | ||
|
||
Return the name of field (or list of names) having the specified value in the given object. | ||
|
||
### getValues(obj: Object): Array | ||
|
||
Return list of field values of specified object. | ||
|
||
### isSizeMore(obj: Object, qty: Number): Boolean | ||
|
||
Check whether number of fields of specified object is more than the given value. | ||
|
||
### split(obj: Object, firstObjFields: Array | Object): Array | ||
|
||
Divide given object into 2 parts: the first part includes specified fields, the second part includes all other fields. | ||
|
||
See `doc` folder for details. | ||
|
||
## Contributing | ||
In lieu of a formal styleguide, take care to maintain the existing coding style. | ||
Add unit tests for any new or changed functionality. | ||
Lint and test your code using [Grunt](http://gruntjs.com/). | ||
|
||
## License | ||
Copyright (c) 2014 Denis Sikuler | ||
Licensed under the MIT license. |
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,32 @@ | ||
{ | ||
"name": "adam", | ||
"main": [ | ||
"dist/adam.js", | ||
"dist/adam.min.js" | ||
], | ||
"version": "0.1.0", | ||
"homepage": "https://github.com/gamtiq/adam", | ||
"authors": [ | ||
"Denis Sikuler" | ||
], | ||
"description": "Functions to process objects", | ||
"keywords": [ | ||
"object", | ||
"process", | ||
"create", | ||
"field", | ||
"value", | ||
"size", | ||
"split", | ||
"filter" | ||
], | ||
"license": "MIT", | ||
"ignore": [ | ||
"**/.*", | ||
"node_modules", | ||
"bower_components", | ||
"sea-modules", | ||
"test", | ||
"tests" | ||
] | ||
} |
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 @@ | ||
{ | ||
"name": "adam", | ||
"repo": "gamtiq/adam", | ||
"description": "Functions to process objects", | ||
"version": "0.1.0", | ||
"keywords": [ | ||
"object", | ||
"process", | ||
"create", | ||
"field", | ||
"value", | ||
"size", | ||
"split", | ||
"filter" | ||
], | ||
"dependencies": {}, | ||
"development": {}, | ||
"license": "MIT", | ||
"main": "src/adam.js", | ||
"scripts": [ | ||
"src/adam.js" | ||
] | ||
} |
Oops, something went wrong.