mirror of
https://github.com/Sevichecc/Urara-Blog.git
synced 2025-05-02 16:49:31 +08:00
24 lines
727 B
Text
24 lines
727 B
Text
/*
|
|
Copyright 2018 Google LLC
|
|
|
|
Use of this source code is governed by an MIT-style
|
|
license that can be found in the LICENSE file or at
|
|
https://opensource.org/licenses/MIT.
|
|
*/
|
|
import { messages } from './messages.js';
|
|
import '../../_version.js';
|
|
const fallback = (code, ...args) => {
|
|
let msg = code;
|
|
if (args.length > 0) {
|
|
msg += ` :: ${JSON.stringify(args)}`;
|
|
}
|
|
return msg;
|
|
};
|
|
const generatorFunction = (code, details = {}) => {
|
|
const message = messages[code];
|
|
if (!message) {
|
|
throw new Error(`Unable to find message for code '${code}'.`);
|
|
}
|
|
return message(details);
|
|
};
|
|
export const messageGenerator = process.env.NODE_ENV === 'production' ? fallback : generatorFunction;
|