How to use the string-template function in string-template

To help you get started, we’ve selected a few string-template examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 715209 / nginx-obs-automatic-low-bitrate-switching / src / components / Chat.js View on Github external
obsinfo() {
        if (this.obsProps.streamStatus != null) {
            const { fps, kbitsPerSec } = this.obsProps.streamStatus;

            this.say(
                format(this.locale.obsinfo.success, {
                    currentScene: this.obsProps.currentScene,
                    fps: Math.round(fps),
                    bitrate: kbitsPerSec
                })
            );
        } else {
            this.say(this.locale.obsinfo.error);
        }
    }
github 715209 / nginx-obs-automatic-low-bitrate-switching / src / components / Chat.js View on Github external
async switch(sceneName) {
        if (sceneName == null) return this.say(this.locale.switch.error);

        const res = search(sceneName, this.obsProps.scenes, { keySelector: obj => obj.name });
        const scene = res.length > 0 ? res[0].name : sceneName;

        try {
            await this.obs.setCurrentScene({
                "scene-name": scene
            });

            this.say(
                format(this.locale.switch.success, {
                    scene
                })
            );
        } catch (e) {
            log.error(e);
            this.say(e.error);
        }
    }
github javascript-obfuscator / javascript-obfuscator / src / custom-nodes / debug-protection-nodes / DebugProtectionFunctionIntervalNode.ts View on Github external
protected getTemplate (): string {
        return format(DebugProtectionFunctionIntervalTemplate(), {
            debugProtectionFunctionName: this.debugProtectionFunctionName
        });
    }
}
github 715209 / nginx-obs-automatic-low-bitrate-switching / src / components / Chat.js View on Github external
config.twitchChat.alias.map((arr, index) => {
                    if (arr[0] == alias) {
                        config.twitchChat.alias.splice(index);
                        delete this.aliases[alias];
                        this.handleWriteToConfig();
                        this.say(
                            format(this.locale.alias.removed, {
                                alias: alias
                            })
                        );
                        exists = true;
                    }
                });
github 715209 / nginx-obs-automatic-low-bitrate-switching / src / components / Chat.js View on Github external
log.success(`Started recording`);
            } catch (error) {
                this.say(
                    format(`[REC] ${this.locale.rec.error}`, {
                        option: this.locale.rec.started
                    })
                );
            }
        } else {
            try {
                const res = await this.obs.StopRecording();
                if (res.status === "ok") this.say(`[REC] ${this.locale.rec.stopped}`);
                log.success(`Stopped recording`);
            } catch (error) {
                this.say(
                    format(` [REC] ${this.locale.rec.error}`, {
                        option: this.locale.rec.stopped
                    })
                );
            }
        }
    }
github javascript-obfuscator / javascript-obfuscator / src / custom-nodes / domain-lock-nodes / DomainLockNode.ts View on Github external
protected getTemplate (): string {
        const domainsString: string = this.options.domainLock.join(';');
        const [hiddenDomainsString, diff]: string[] = this.cryptUtils.hideString(
            domainsString,
            domainsString.length * 3
        );
        const globalVariableTemplate: string = this.options.target !== ObfuscationTarget.BrowserNoEval
            ? this.getGlobalVariableTemplate()
            : GlobalVariableNoEvalTemplate();

        return format(DomainLockNodeTemplate(), {
            domainLockFunctionName: this.identifierNamesGenerator.generate(),
            diff: diff,
            domains: hiddenDomainsString,
            globalVariableTemplate,
            singleNodeCallControllerFunctionName: this.callsControllerFunctionName
        });
    }
}
github javascript-obfuscator / javascript-obfuscator / src / custom-nodes / string-array-nodes / StringArrayCallsWrapper.ts View on Github external
switch (this.options.stringArrayEncoding) {
            case StringArrayEncoding.Rc4:
                decodeStringArrayTemplate = format(
                    StringArrayRc4DecodeNodeTemplate(this.randomGenerator),
                    {
                        atobPolyfill,
                        rc4Polyfill: Rc4Template(),
                        selfDefendingCode,
                        stringArrayCallsWrapperName: this.stringArrayCallsWrapperName
                    }
                );

                break;

            case StringArrayEncoding.Base64:
                decodeStringArrayTemplate = format(
                    StringArrayBase64DecodeNodeTemplate(this.randomGenerator),
                    {
                        atobPolyfill,
                        selfDefendingCode,
                        stringArrayCallsWrapperName: this.stringArrayCallsWrapperName
                    }
                );
        }

        return decodeStringArrayTemplate;
    }
}
github danludwig / eventsourced.net / src / EventSourced.Net.Web / Web / Shared / selectors / fetchNetworkError.js View on Github external
export default action => {
  const errors = {}, { error, payload } = action
  if (error === true && payload.status !== 400) {
    let message = errorMessages.unknown
    if (payload && payload.statusText) {
      const template = errorMessages.api[camelize(payload.statusText)]
      if (template) {
        message = errorMessages.unexpected + ' ' + template
      }
    }
    else if (payload && payload.name && payload.message) {
      const template = errorMessages.api[camelize(payload.name)]
      if (template) {
        message = format(template, payload)
        const camelizedMessage = camelize(payload.message)
        if (errorMessages.api[camelizedMessage])
          message = errorMessages.unexpected + ' ' + errorMessages.api[camelizedMessage]
      }
    }
    errors._error = message
  }
  return errors
}
github BrooklynKing / Grimsonland / js / configs / rules.js View on Github external
init: function (dt, obj) {
            var obj = this.context;
            obj.parameters.text = format(obj.parameters.template, {
                time: ((obj.layer.game.parameters.bestTime) / 60).toFixed(2)
            });
        }
    },
github danludwig / eventsourced.net / src / EventSourced.Net.Web / Web / Shared / selectors / socketReversalErrors.js View on Github external
export default (formInput, action, messages) => {
  if (!action || !action.payload || !action.payload.errors) return undefined
  const { errors } = action.payload
  const _error = errorMessages.unexpected
  if (!errors) return { _error }

  const formErrors = {}
  for (const field in errors) {
    if (!errors.hasOwnProperty(field) || !errors[field] || !errors[field].reasonText) continue
    const reason = camelize(errors[field].reasonText)
    const tokens = { ...formInput }
    if (!tokens[field]) tokens[field] = errors[field].value
    let message = _error
    if (messages && messages[field] && messages[field][reason]) {
      message = format(messages[field][reason], tokens)
    }
    if (formInput && formInput.hasOwnProperty(field)) {
      formErrors[field] = message
    }
    else if (!formErrors._error) {
      formErrors._error = message
    }
  }
  return formErrors
}

string-template

A simple string template function based on named or indexed arguments

MIT
Latest version published 8 years ago

Package Health Score

67 / 100
Full package analysis

Popular string-template functions