Skip to content

Commit e04d4ce

Browse files
committedMar 1, 2015
Initial commit
0 parents  commit e04d4ce

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed
 

‎.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
*.log

‎index.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = function(model) {
2+
model.get(function(value, type) {
3+
return value === undefined
4+
? type.defaultValue
5+
: value;
6+
});
7+
8+
model.default = function(value) {
9+
return this.use(function(model) {
10+
model.defaultValue = value;
11+
});
12+
};
13+
};

‎package.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "defaults",
3+
"version": "0.1.0",
4+
"description": "Add default value support to immodel",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "mocha"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "http://github.com/immodel/defaults"
12+
},
13+
"keywords": [
14+
"defaults",
15+
"immodel",
16+
"default",
17+
"values"
18+
],
19+
"author": "ashaffer (http://github.com/ashaffer)",
20+
"license": "MIT",
21+
"bugs": {
22+
"url": "https://github.com/immodel/defaults/issues"
23+
},
24+
"homepage": "https://github.com/immodel/defaults"
25+
}

0 commit comments

Comments
 (0)
Please sign in to comment.