MCPcopy Index your code
hub / github.com/angular/angular / i18nCreateOpCodesToString

Function i18nCreateOpCodesToString

packages/core/src/render3/i18n/i18n_debug.ts:38–61  ·  view source on GitHub ↗
(
  this: I18nCreateOpCodes | void,
  opcodes?: I18nCreateOpCodes,
)

Source from the content-addressed store, hash-verified

36 * @param opcodes `I18nCreateOpCodes` if invoked as a function.
37 */
38export function i18nCreateOpCodesToString(
39 this: I18nCreateOpCodes | void,
40 opcodes?: I18nCreateOpCodes,
41): string[] {
42 const createOpCodes: I18nCreateOpCodes = opcodes || (Array.isArray(this) ? this : ([] as any));
43 let lines: string[] = [];
44 for (let i = 0; i < createOpCodes.length; i++) {
45 const opCode = createOpCodes[i++] as any;
46 const text = createOpCodes[i] as string;
47 const isComment = (opCode & I18nCreateOpCode.COMMENT) === I18nCreateOpCode.COMMENT;
48 const appendNow =
49 (opCode & I18nCreateOpCode.APPEND_EAGERLY) === I18nCreateOpCode.APPEND_EAGERLY;
50 const index = opCode >>> I18nCreateOpCode.SHIFT;
51 lines.push(
52 `lView[${index}] = document.${isComment ? 'createComment' : 'createText'}(${JSON.stringify(
53 text,
54 )});`,
55 );
56 if (appendNow) {
57 lines.push(`parent.appendChild(lView[${index}]);`);
58 }
59 }
60 return lines;
61}
62
63/**
64 * Converts `I18nUpdateOpCodes` array into a human readable format.

Callers 1

i18n_debug_spec.tsFile · 0.90

Calls 2

isArrayMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…