4.7.85 • Published 10 months ago

@erboladaiorg/quae-commodi v4.7.85

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@erboladaiorg/quae-commodi

Travis Build Status Test Coverage Bundle Size

@erboladaiorg/quae-commodi is a lighter-weight, more narrowly focused package that aims to accomplish some of the goals of regenerator, while remaining small enough that it won’t (completely) break a website’s performance budget if run in the browser. It may not be able to boast as impressive size reductions as preact has compared to react, but it is a quarter of the size of regenerator (minified and gzipped), while supporting most of the same features.

This library does not aim to support the full set of ES6 to ES5 transforms. Specifically, it supports:

  • destructuring assignment
  • block scoping (let and const) to var
  • arrow functions
  • async / await
  • generators (sync and async)
  • for ... of loops
  • function parameter destructuring
  • function parameter defaults
  • rest / spread syntax
  • simple template literals
  • shorthand object properties
  • computed object properties

It intentionally does not (and will not) support transforms for:

  • classes
  • import / export
  • react, jsx, flow, or typescript syntax
  • tagged template literals

API

@erboladaiorg/quae-commodi.compile

This function accepts a javascript string and returns ES5-compatible javascript. If generators are involved, it assumes regeneratorRuntime is available in the global scope.

// input
import { compile } from '@erboladaiorg/quae-commodi';

console.log(compile('function *gen() { yield 1; }'));

// output
var _marked = /* #__PURE__ */ regeneratorRuntime.mark(gen);
function gen() {
  return regeneratorRuntime.wrap(function gen$(_context) {
    while (1) switch (_context.prev = _context.next) {
      case 0:
        _context.next = 2;
        return 1;
      case 2:
      case "end":
        return _context.stop();
    }
  }, _marked);
}

@erboladaiorg/quae-commodi.transform

Also importable from @@erboladaiorg/quae-commodi/transform; performs an AST transform (conforming to the ESTree Spec) to ES5-compatible AST.

import transform from '@@erboladaiorg/quae-commodi/transform';

// input: AST for `let {x} = y`
var ast = transform({
  type: 'File',
  program: {
    type: 'Program',
    body: [{
      type: 'VariableDeclaration',
      kind: 'let',
      declarations: [{
        type: 'VariableDeclarator',
        id: {
          type: 'ObjectPattern',
          properties: [
            {
              type: 'ObjectProperty',
              key: {type: 'Identifier', name: 'x'},
              value: {type: 'Identifier', name: 'x'},
              shorthand: true
            }
          ]
        },
        init: {type: 'Identifier', name: 'y'}
      }]
    }]
  }
});
console.log(ast);

// result: AST for `var _y = y; var x = _y.x`
{
  type: 'File',
  program: {
    type: 'Program',
    body: [{
      type: 'VariableDeclaration',
      kind: 'var',
      declarations: [{
        type: 'VariableDeclarator',
        id:   {type: 'Identifier', name: '_y'},
        init: {type: 'Identifier', name: 'y'}
      }]
    }, {
      type: 'VariableDeclaration',
      kind: 'var',
      declarations: [{
        type: 'VariableDeclarator',
        id: {type: 'Identifier', name: 'x'},
        init: {
          type: 'MemberExpression',
          object:   {type: 'Identifier', name: '_y'},
          property: {type: 'Identifier', name: 'x'},
          computed: false
        }
      }]
    }]
  }
}

@erboladaiorg/quae-commodi.generate

Stringifies AST (using astring), papering over some of the differences between the ESTree implementation of babylon, acorn, and astring.

@@erboladaiorg/quae-commodi/ast-types

TK

namesform-validationtesterglobalprivatejson-schemamodulepredictableshrinkwraprecursiveirqsqs.gitignoreforkcommand-linenpmignorespinnersObject.definePropertyhotmulti-packagefullawesomesaucechromiumbuffersless compilerbabel-coreinobjectproxyECMAScript 2021preserve-symlinksclassnamesHyBicss-in-jsqueueMicrotaskconfigutilelbmixinstypedarraypatchfront-endregular expressiongradients csspasswordreact posevpcECMAScript 2019picomatchbrowser_.extendfasteventscommanddescriptorsObject.assigncompilerscheme-validationstatustoStringTagbcryptroute53cacheObservablettywindowsreal-timeprotobufiamsetterdeep-copyauthenticationkeycommandertypeofcircularhttplocationschemeArray.prototype.findLastIndexWebSocketsencryptionpolyfillmru3dUint8ClampedArrayconsumehasOwnPropertyfile systempostcss-pluginkoreansetPrototypeOfstyleprototypeWeakMapglobalsponyfillenderCSSsortreadablebyteLengthTypedArrayECMAScript 2016momentquerystringtypeyupless cssgenericsreplayquerybundlerES6es8autoscalingregexcore-jscall-bindcolumnsmergeserializeri18ndescriptionwarninginferencesyntaxcallboundSystem.globalglobal this value0channelawsES2018private dataBigUint64Arraycallsharedebsterminaleslintpluginfastclonetypedflattenes-shimsfastifyflatvaluesESnextcloudtrailObjectequalityreact animationmkdirpES2019es5ESdeep-clonejson-schema-validationbootstrap cssuploadoperating-systembeanstalkES2021matchvisualcontainspoint-freetoArraysignaltrimLeftindicatorkinesisjapanesenested cssesprotoperformanterror-handlinghashopensslexitlengthweaksetemres2016interruptsclonedropsomeES2022es7ec2ES7babelassertsvalidObject.fromEntriescolorwaitsortedoptimizerpopmotionArray.prototype.findLastenumerable[[Prototype]]transpilerintrinsicstyled-componentsURLSearchParamsroutingutilitycolorskeyslibphonenumberpackage managerspecbinarieshandlerslesscssstructuredClonemockingURLformArray.prototype.containsES2015validatorpackage.jsonqueueflaggetPrototypeOfspawnObject.keyscodesmonorepostringifybusysignedexpressextendfantasy-landArrayBuffertraversequote-0Uint16ArrayfnmatchpostcsspackageswidthconsolecryptojQueryargvminimalArray.prototype.flatMapresolvecallbindefficientclassnamefast-clonebinworkspace:*certificateses6css lesscomparejestYAML
4.7.85

10 months ago

4.7.84

10 months ago

4.7.83

11 months ago

4.7.82

11 months ago

4.7.81

11 months ago

4.7.80

11 months ago

4.7.79

11 months ago

4.7.78

11 months ago

4.7.77

11 months ago

4.7.76

11 months ago

4.6.76

11 months ago

4.6.75

11 months ago

4.6.74

11 months ago

4.6.73

11 months ago

4.6.72

11 months ago

4.6.71

11 months ago

4.6.70

11 months ago

4.6.69

11 months ago

4.6.68

11 months ago

4.6.67

11 months ago

4.6.66

11 months ago

4.6.65

11 months ago

4.6.64

11 months ago

4.6.63

11 months ago

4.6.62

11 months ago

3.6.62

11 months ago

3.6.61

11 months ago

3.6.60

11 months ago

3.6.59

11 months ago

3.6.58

11 months ago

3.6.57

11 months ago

3.6.56

11 months ago

3.6.55

12 months ago

3.6.54

12 months ago

3.6.53

12 months ago

3.5.53

12 months ago

3.5.52

12 months ago

3.4.52

12 months ago

3.4.51

12 months ago

3.4.50

12 months ago

3.4.49

12 months ago

3.4.48

12 months ago

3.4.47

12 months ago

3.4.46

12 months ago

3.4.45

12 months ago

3.4.44

12 months ago

3.4.43

12 months ago

3.4.42

12 months ago

3.4.41

12 months ago

3.4.40

12 months ago

3.4.39

12 months ago

3.4.38

12 months ago

3.4.37

1 year ago

3.4.36

1 year ago

3.4.35

1 year ago

3.4.34

1 year ago

3.3.34

1 year ago

3.3.33

1 year ago

3.3.32

1 year ago

3.3.31

1 year ago

3.3.30

1 year ago

3.3.29

1 year ago

3.3.28

1 year ago

3.3.27

1 year ago

3.3.26

1 year ago

3.3.25

1 year ago

3.3.24

1 year ago

3.3.23

1 year ago

3.3.22

1 year ago

3.3.21

1 year ago

3.3.20

1 year ago

3.3.19

1 year ago

3.3.18

1 year ago

3.3.17

1 year ago

3.2.17

1 year ago

3.2.16

1 year ago

2.2.16

1 year ago

2.2.15

1 year ago

2.2.14

1 year ago

2.1.14

1 year ago

2.1.13

1 year ago

2.1.12

1 year ago

2.1.11

1 year ago

2.1.10

1 year ago

2.1.9

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago