Skip to content

Commit

Permalink
Dev: Object abstract function order
Browse files Browse the repository at this point in the history
  • Loading branch information
surunzi committed Apr 27, 2017
1 parent 3e5fd85 commit c60f6fc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
"devDependencies": {
"autoprefixer": "^6.3.3",
"babel-core": "^6.6.5",
"babel-loader": "^6.2.4",
"babel-loader": "^7.0.0",
"babel-plugin-transform-runtime": "^6.8.0",
"babel-preset-es2015": "^6.6.0",
"css-loader": "^0.26.2",
"css-loader": "^0.28.0",
"draggabilly": "^2.1.0",
"handlebars": "^4.0.5",
"handlebars-loader": "^1.1.4",
Expand Down
17 changes: 15 additions & 2 deletions src/lib/getAbstract.es6
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default function getAbstract(obj, {
i = 1;
json = '{ ';
util.each(names, objIteratee);
json += parts.join(', ') + objEllipsis + ' }';
json += moveFnToTail(parts).join(', ') + objEllipsis + ' }';
} else
{
json = util.getObjType(obj);
Expand Down Expand Up @@ -168,7 +168,7 @@ export default function getAbstract(obj, {
json = '{ ';
names = unenumerable ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
util.each(names, objIteratee);
json += parts.join(', ') + objEllipsis + ' }';
json += moveFnToTail(parts).join(', ') + objEllipsis + ' }';
} else
{
json = util.getObjType(obj);
Expand All @@ -191,3 +191,16 @@ function canBeProto(obj)

return emptyObj && proto && proto !== Object.prototype;
}

function moveFnToTail(parts)
{
var front = [],
tail = [];

util.each(parts, val =>
{
val.indexOf('function') > -1 ? tail.push(val) : front.push(val);
});

return front.concat(tail);
}

0 comments on commit c60f6fc

Please sign in to comment.