Skip to content

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
gamtiq committed Sep 7, 2014
1 parent dcb311b commit feb00e1
Show file tree
Hide file tree
Showing 54 changed files with 102,592 additions and 24 deletions.
8 changes: 8 additions & 0 deletions .gitignore
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
16 changes: 16 additions & 0 deletions .jshintrc
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
}
9 changes: 9 additions & 0 deletions .spmignore
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
112 changes: 112 additions & 0 deletions Gruntfile.js
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 added History.md
Empty file.
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

22 changes: 22 additions & 0 deletions LICENSE-MIT
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.
131 changes: 128 additions & 3 deletions README.md
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.

[![NPM version](https://badge.fury.io/js/adam.png)](http://badge.fury.io/js/adam)
[![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](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, &lt;script&gt;

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, &lt;script&gt;

```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: &lt;prefix&gt;&lt;number&gt;

### 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.
32 changes: 32 additions & 0 deletions bower.json
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"
]
}
23 changes: 23 additions & 0 deletions component.json
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"
]
}
Loading

0 comments on commit feb00e1

Please sign in to comment.