How to use caffeine-script-runtime - 10 common examples

To help you get started, we’ve selected a few caffeine-script-runtime 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 caffeine-suite / caffeine-script / source / CaffeineScript / Lib.js View on Github external
escapeUnescaped: function(string, charsToEscape = '"') {
          let charsRegExp, split;
          charsRegExp = RegExp(
            `([${Caf.toString(escapeRegExp(charsToEscape))}])`,
            "g"
          );
          split = charsToEscape.match(/\\/)
            ? [string]
            : string.split(/((?:\\.)+)/);
          return Caf.array(split, (str, i) =>
            Caf.mod(i, 2) === 0 ? str.replace(charsRegExp, "\\$1") : str
          ).join("");
        },
        legalUnquotedPropName: (legalUnquotedPropName = /^(0|[1-9][0-9]*|[a-z_][0-9_a-z]*)$/i),
github caffeine-suite / caffeine-script / source / CaffeineScript / Lib.js View on Github external
deescapeSpaces: (deescapeSpaces = function(string) {
          return Caf.array(string.split(/((?:\\\\)+)/), (str, i) =>
            Caf.mod(i, 2) === 0 ? str.replace(/\\[_ ]/g, " ") : str
          ).join("");
        }),
        escapeNewLines: function(string) {
github caffeine-suite / caffeine-script / source / CaffeineScript / SemanticTree / ScopeStnMixin.js View on Github external
this.prototype.getBareInitializers = function() {
              let identifiers;
              this.bindAllUniqueIdentifiersRequested();
              return this._identifiersAssigned &&
                (identifiers = this.requiredIdentifierLets).length > 0
                ? ((identifiers = Caf.array(identifiers, null, identifier =>
                    identifier.match(/=/)
                  )),
                  identifiers.length > 0
                    ? `${Caf.toString(identifiers.join("; "))}`
                    : undefined)
                : undefined;
            };
            this.prototype.updateScope = function(scope) {
github caffeine-suite / caffeine-script / source / CaffeineScript / SemanticTree / StnsGeneratingJs / ClassStn.js View on Github external
FunctionDefinitionArgStn(
                    IdentifierStn({ identifier: className })
                  ),
                  FunctionDefinitionArgStn(
                    IdentifierStn({
                      identifier: (classSuperHandle = "classSuper")
                    })
                  ),
                  FunctionDefinitionArgStn(
                    IdentifierStn({
                      identifier: (instanceSuperHandle = "instanceSuper")
                    })
                  )
                ),
                StatementsStn(
                  (statementsToCount = Caf.array(body.children, stn =>
                    stn.type === "Object"
                      ? Caf.array(stn.children, objectPropValueStn => {
                          let propNameStn,
                            propValueStn,
                            assignToStn,
                            propName,
                            isThisProp;
                          [
                            propNameStn,
                            propValueStn
                          ] = objectPropValueStn.children;
                          assignToStn = (() => {
                            switch (propNameStn.type) {
                              case "ObjectPropName":
                                ({ propName, isThisProp } = propNameStn);
                                return isThisProp
github caffeine-suite / caffeine-script / source / CaffeineScript / SemanticTree / JustToJsWithTransforms / ClassStn.js View on Github external
FunctionDefinitionArgStn(
                    IdentifierStn({ identifier: className })
                  ),
                  FunctionDefinitionArgStn(
                    IdentifierStn({
                      identifier: (classSuperHandle = "classSuper")
                    })
                  ),
                  FunctionDefinitionArgStn(
                    IdentifierStn({
                      identifier: (instanceSuperHandle = "instanceSuper")
                    })
                  )
                ),
                StatementsStn(
                  (statementsToCount = Caf.array(
                    body.children,
                    stn =>
                      stn.type === "Object"
                        ? Caf.array(stn.children, objectPropValueStn => {
                            let propNameStn,
                              propValueStn,
                              assignToStn,
                              propName,
                              isThisProp;
                            [
                              propNameStn,
                              propValueStn
                            ] = objectPropValueStn.children;
                            assignToStn = (() => {
                              switch (propNameStn.type) {
                                case "ObjectPropName":
github caffeine-suite / caffeine-script / source / CaffeineScript / SemanticTree / ComprehensionStn.js View on Github external
return (() => {
                    throw new Error(
                      `not supported yet: ${Caf.toString(outputType)}`
                    );
                  })();
              }
github caffeine-suite / caffeine-script / source / CaffeineScript / SemanticTree / TryStn.js View on Github external
this.prototype.toJs = function(options = {}) {
        let returnExpression, body, optionalCatch;
        ({ returnExpression } = options);
        ({ body, optionalCatch } = this.labeledChildren);
        body = returnExpression ? body.toFunctionBodyJs() : body.toJs();
        optionalCatch = Caf.exists(optionalCatch) &&
          optionalCatch.toJs(options) ||
          "catch (cafError) {}";
        return `try {${Caf.toString(body)};} ${Caf.toString(optionalCatch)}`;
      };
      this.prototype.toJsExpression = function() {
github caffeine-suite / caffeine-script / source / CaffeineScript / SemanticTree / ComplexToJs / TryStn.js View on Github external
this.prototype.toJs = function(options = {}) {
        let expression, body, optionalCatch, js;
        ({ expression } = options);
        ({ body, optionalCatch } = this.labeledChildren);
        body = expression ? body.toFunctionBodyJs() : body.toJs();
        optionalCatch = Caf.exists(optionalCatch) &&
          optionalCatch.toJs(options) ||
          "catch (cafError) {}";
        js = `try {${Caf.toString(body)};} ${Caf.toString(optionalCatch)}`;
        return expression ? this.doJs(null, js) : js;
      };
    }
github caffeine-suite / caffeine-script / source / CaffeineScript / SemanticTree / ComplexToJs / ThrowStn.js View on Github external
"use strict";
let Caf = require("caffeine-script-runtime");
Caf.defMod(module, () => {
  let ThrowStn;
  return ThrowStn = Caf.defClass(
    class ThrowStn extends require("../BaseStn") {},
    function(ThrowStn, classSuper, instanceSuper) {
      this.prototype.toJs = function(options = {}) {
        return options.expression
          ? `(()=>{${Caf.toString(this.toJs())};})()`
          : `throw ${Caf.toString(this.childrenToJs())}`;
      };
    }
  );
});
github caffeine-suite / caffeine-script / source / CaffeineScript / SemanticTree / JustToJs / ArraySpreadElementStn.js View on Github external
"use strict";
let Caf = require("caffeine-script-runtime");
Caf.defMod(module, () => {
  return (() => {
    let ArraySpreadElementStn;
    return (ArraySpreadElementStn = Caf.defClass(
      class ArraySpreadElementStn extends require("../BaseStn") {},
      function(ArraySpreadElementStn, classSuper, instanceSuper) {
        this.prototype.toSourceNode = function() {
          return this.createSourceNode("...", this.childrenToSourceNodes());
        };
      }
    ));
  })();
});

caffeine-script-runtime

Runtime library for CaffeineScript

ISC
Latest version published 4 years ago

Package Health Score

45 / 100
Full package analysis

Similar packages