Files
react-native/Libraries/Utilities/nativeModulePrefixDuplicator.js
Christopher Chedeau f7cf017d29 Updates from Tue 17 Mar
- [ReactNative] Remove pushNotification prop from renderApplication | Eric Vicenti
- [react_native] Stub VibrationIOS on Android | Andy Street
- [ReactNative] Simplify and test interpolators | Christopher Chedeau
- [ReactNative] Increase timeout for obj-c tests | Christopher Chedeau
- [ReactNative] Updated RKText to new UIManager system | Nick Lockwood
- [ReactNative] Unforked RCTShadowView, moved RKTextView into FBReactKitTextModule | Nick Lockwood
- [ReactKit] Remove NativeModulesDeprecated | Spencer Ahrens
- [ReactNative] Allow single callbacks in NativeModules | Spencer Ahrens
- [ReactNative] s/RK/RCT in OSS | Spencer Ahrens
- [ReactNative] Cleanup StyleSheet API | Christopher Chedeau
- [RCTVibration] Basic Vibration API | Christopher Chedeau
- [React Native] Prevent crash in redbox code with two thrown errors | Ben Alpert
- [ReactNative] unbreak Android | Andrew Rasmussen
2015-03-17 13:43:53 -07:00

26 lines
809 B
JavaScript

/**
* Copyright 2004-present Facebook. All Rights Reserved.
*
* @providesModule nativeModulePrefixDuplicator
*/
'use strict';
// Dirty hack to support old (RK) and new (RCT) native module name conventions
function nativeModulePrefixDuplicator(modules) {
Object.keys(modules).forEach((moduleName) => {
var rkModuleName = moduleName.replace(/^RCT/, 'RK');
var rctModuleName = moduleName.replace(/^RK/, 'RCT');
if (rkModuleName !== rctModuleName) {
if (modules[rkModuleName] && modules[rctModuleName]) {
throw new Error(
'Module cannot be registered as both RCT and RK: ' + moduleName
);
}
modules[rkModuleName] = modules[moduleName];
modules[rctModuleName] = modules[moduleName];
}
});
}
module.exports = nativeModulePrefixDuplicator;