e9ff7bbe0db09c91523919fcc367bc4c86da8b85
[platform/framework/web/crosswalk-tizen.git] /
1 "use strict";
2
3 module.exports = protochain;
4
5 function protochain(obj) {
6   var result = [];
7   var target = getPrototypeOf(obj);
8   while (target) {
9     result.push(target);
10     target = getPrototypeOf(target);
11   }
12
13   return result;
14 }
15
16 function getPrototypeOf(obj) {
17   if (obj == null) {
18     return obj;
19   }if (isPrimitive(obj)) obj = Object(obj);
20   return Object.getPrototypeOf(obj);
21 }
22
23 function isPrimitive(item) {
24   return item === null || typeof item !== "object";
25 }
26