source: trip-planner-front/node_modules/prr/prr.js@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.5 KB
RevLine 
[6a3a178]1/*!
2 * prr
3 * (c) 2013 Rod Vagg <rod@vagg.org>
4 * https://github.com/rvagg/prr
5 * License: MIT
6 */
7
8(function (name, context, definition) {
9 if (typeof module != 'undefined' && module.exports)
10 module.exports = definition()
11 else
12 context[name] = definition()
13})('prr', this, function() {
14
15 var setProperty = typeof Object.defineProperty == 'function'
16 ? function (obj, key, options) {
17 Object.defineProperty(obj, key, options)
18 return obj
19 }
20 : function (obj, key, options) { // < es5
21 obj[key] = options.value
22 return obj
23 }
24
25 , makeOptions = function (value, options) {
26 var oo = typeof options == 'object'
27 , os = !oo && typeof options == 'string'
28 , op = function (p) {
29 return oo
30 ? !!options[p]
31 : os
32 ? options.indexOf(p[0]) > -1
33 : false
34 }
35
36 return {
37 enumerable : op('enumerable')
38 , configurable : op('configurable')
39 , writable : op('writable')
40 , value : value
41 }
42 }
43
44 , prr = function (obj, key, value, options) {
45 var k
46
47 options = makeOptions(value, options)
48
49 if (typeof key == 'object') {
50 for (k in key) {
51 if (Object.hasOwnProperty.call(key, k)) {
52 options.value = key[k]
53 setProperty(obj, k, options)
54 }
55 }
56 return obj
57 }
58
59 return setProperty(obj, key, options)
60 }
61
62 return prr
63})
Note: See TracBrowser for help on using the repository browser.