This app provides monitoring and information features for the common freifunk user and the technical stuff of a freifunk community.
Code base is taken from a TUM Practical Course project and added here to see if Freifunk Altdorf can use it.
https://www.freifunk-altdorf.de
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.5 KiB
56 lines
1.5 KiB
'use strict'; |
|
|
|
var keys = require('object-keys'); |
|
var foreach = require('foreach'); |
|
var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol'; |
|
|
|
var toStr = Object.prototype.toString; |
|
|
|
var isFunction = function (fn) { |
|
return typeof fn === 'function' && toStr.call(fn) === '[object Function]'; |
|
}; |
|
|
|
var arePropertyDescriptorsSupported = function () { |
|
var obj = {}; |
|
try { |
|
Object.defineProperty(obj, 'x', { enumerable: false, value: obj }); |
|
/* eslint-disable no-unused-vars, no-restricted-syntax */ |
|
for (var _ in obj) { return false; } |
|
/* eslint-enable no-unused-vars, no-restricted-syntax */ |
|
return obj.x === obj; |
|
} catch (e) { /* this is IE 8. */ |
|
return false; |
|
} |
|
}; |
|
var supportsDescriptors = Object.defineProperty && arePropertyDescriptorsSupported(); |
|
|
|
var defineProperty = function (object, name, value, predicate) { |
|
if (name in object && (!isFunction(predicate) || !predicate())) { |
|
return; |
|
} |
|
if (supportsDescriptors) { |
|
Object.defineProperty(object, name, { |
|
configurable: true, |
|
enumerable: false, |
|
value: value, |
|
writable: true |
|
}); |
|
} else { |
|
object[name] = value; |
|
} |
|
}; |
|
|
|
var defineProperties = function (object, map) { |
|
var predicates = arguments.length > 2 ? arguments[2] : {}; |
|
var props = keys(map); |
|
if (hasSymbols) { |
|
props = props.concat(Object.getOwnPropertySymbols(map)); |
|
} |
|
foreach(props, function (name) { |
|
defineProperty(object, name, map[name], predicates[name]); |
|
}); |
|
}; |
|
|
|
defineProperties.supportsDescriptors = !!supportsDescriptors; |
|
|
|
module.exports = defineProperties;
|
|
|