Add files
This commit is contained in:
commit
bb80829159
18195 changed files with 2122994 additions and 0 deletions
61
509bba0_unpacked_with_node_modules/~/keymirror/index.js
generated
Executable file
61
509bba0_unpacked_with_node_modules/~/keymirror/index.js
generated
Executable file
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
* Copyright 2013-2014 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Constructs an enumeration with keys equal to their value.
|
||||
*
|
||||
* For example:
|
||||
*
|
||||
* var COLORS = keyMirror({blue: null, red: null});
|
||||
* var myColor = COLORS.blue;
|
||||
* var isColorValid = !!COLORS[myColor];
|
||||
*
|
||||
* The last line could not be performed if the values of the generated enum were
|
||||
* not equal to their keys.
|
||||
*
|
||||
* Input: {key1: val1, key2: val2}
|
||||
* Output: {key1: key1, key2: key2}
|
||||
*
|
||||
* @param {object} obj
|
||||
* @return {object}
|
||||
*/
|
||||
var keyMirror = function(obj) {
|
||||
var ret = {};
|
||||
var key;
|
||||
if (!(obj instanceof Object && !Array.isArray(obj))) {
|
||||
throw new Error('keyMirror(...): Argument must be an object.');
|
||||
}
|
||||
for (key in obj) {
|
||||
if (!obj.hasOwnProperty(key)) {
|
||||
continue;
|
||||
}
|
||||
ret[key] = key;
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
module.exports = keyMirror;
|
||||
|
||||
|
||||
|
||||
//////////////////
|
||||
// WEBPACK FOOTER
|
||||
// ./~/keymirror/index.js
|
||||
// module id = 253
|
||||
// module chunks = 4
|
Loading…
Add table
Add a link
Reference in a new issue