Urara-Blog/node_modules/.pnpm-store/v3/files/81/4bb6ac5ad48b71a10c4ee4ebcf5e01a9c8dd42f94d20388e51fee0c492602ea6dcbe3d74bc2f01e4664bf9e0d5d92bfdd1f7766b54c72ee2010f07cb298230
2022-08-14 01:14:53 +08:00

30 lines
731 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: string, ...args: any[]) => {
let msg = code;
if (args.length > 0) {
msg += ` :: ${JSON.stringify(args)}`;
}
return msg;
};
const generatorFunction = (code: string, 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;