-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.js
25 lines (22 loc) · 872 Bytes
/
model.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
'use strict';
var Model = require('model');
module.exports = Model().attr('file')
.attr('url')
.attr('status', {default: 'new'})
.attr('error')
.attr('progress')
.attr('uploadedTime')
.calc('name', getFrom('file', 'name') )
.calc('size', getFrom('file', 'size') )
.calc('type', getFrom('file', 'type') )
.calc('lastModifiedDate', getFrom('file', 'lastModifiedDate') )
.calc('baseName', function(d){
var name = d.file && d.file.name;
return name && name.split(/[\\/]/).pop();
})
;
function getFrom(from, prop){
return function(d){
return d[from] && d[from][prop];
}
}