mirror of
https://github.com/status-im/react-native.git
synced 2025-01-10 01:25:39 +00:00
26 lines
809 B
JavaScript
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;
|