Code Monkey home page Code Monkey logo

nodejs-closure-serializer's Introduction


Functionless

Build serverless AWS applications with type-safe Components and easy-to-follow Conventions.

MIT License Discord Twitter

๐Ÿ› ย  Functionless is in pre-release - come chat to us on Discord!


Overview

Website โ€ข API Docs โ€ข Getting Started

Functionless is a full-stack framework that enables you to easily build type-safe cloud applications on AWS serverless without writing CloudFormation or complex infrastructure configuration.

  • ๐Ÿช‚ย  Type-safe AWS cloud resources such as Rest APIs, GraphQL APIs, Lambda Functions, DynamoDB Tables, Step Functions, Event Bridge, and more.
  • ๐Ÿ‘จโ€๐Ÿ’ปย  Local development experience for AWS serverless.
  • ๐Ÿžย  Instant feedback with step-through debugger.
  • ๐Ÿง™ย  Architecture-aware CLI for operating, maintaining and testing cloud resources.
  • ๐Ÿ”ย  Guaranteed least-privilege automatically derived IAM Policies.
  • ๐ŸŽขย  NextJS-like file system conventions for CloudFormation Stacks and APIs.
  • ๐Ÿงฉย  Build and share custom re-usable cloud components.

Quick Start

# create a new project
npx create-functionless@latest
cd <project-name>

# deploy to AWS
npx fl deploy

# open my-function in the AWS console
npx fl ./src/my-function console

# run your application locally
npx fl local

Why Functionless?

Functionless re-imagines Infrastructure-as-Code (IaC) as Infrastructure-from-Code (IfC). Enjoy a streamlined developer experience for full stack developers without giving up control of your AWS infrastructure.

๐Ÿง  Intuitive

We provide guardrails to accelerate development of serverless applications. Use simple file system conventions to organize your cloud resources such as Stacks, APIs, Functions, Workflows, Databases, and more.

๐Ÿš€ Productive

Designed for instant feedback. Catch errors in real-time before deployment with type-safe Runtime APIs; test and debug locally; automate operational tasks with an application-aware CLI experience.

Type-safe Cloud Resources

๐Ÿ‘ฎโ€โ™€๏ธ Secure

Built with safety and security in mind. Our compiler automatically guarantees your serverless Resources are configured with IAM Policies that only have access to what they need - no more and no less.

๐Ÿ’ช Powerful

Build and share custom components and integrate them into your application. Each component exposes a Runtime and Operational interface for production-ready use.

nodejs-closure-serializer's People

Contributors

sam-goodwin avatar thantos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nodejs-closure-serializer's Issues

`with` degrades performance significantly

The way the closure serializer wraps closures in a with degrades performance by approximately 4-5x. See below for an example.

function foo() {
  with({
    a: "hello"
  }) {
    return (function() {
      return function() {
        return arguments * 10 ;
      }
    }).apply(undefined, undefined).apply(this, arguments);
  }
}


function foo2() {
  return (function() {
    return function() {
      return arguments * 10;
    }
  }).apply(undefined, undefined).apply(this, arguments)
}

for (let j = 0; j < 10; j++) {
  const start = new Date();
  for (let i = 0; i < 10*1000*1000; i++) {
    foo2(i);
  }
  
  console.log(new Date().getTime() - start.getTime());
}

Maintain references to closured `let` and `var`

Closure serialization should maintain references to closured let and var and all modifications of that value should reflect everywhere it is referenced.

Below is a test case that should pass, with expectResult: 2, but the result is 0 - because the closured let is re-declared in each closure and copied by-value, not by-ref. This is true even when using the previous with technique.

let i = 0;
function a() {
  i += 1;
}
function b() {
  i += 1;
}

cases.push({
  title: "two functions modifying a single let have changes reflected",
  func: () => {
    a();
    b();
    return i;
  },
  snapshot: true,
  expectResult: 2,
});

Update the serialize contract

The repo is a fork of @pulumi/pulumi's closure serializer.

One of the changes to the original repo was to support replacement of objects to be serialized using the serialize callback.

The current implementation supports the contract (o: any) => boolean | any where:

  • true - serialize o as is - original contract
  • false - do not serialize o (replace with undefined) - original contract
  • anything else - replace o with the value

This contract isn't great, but it was a quick update from the original contract.

We should update this to support the edge case where a boolean value should replace the original value.

Proposal:

/**
 * return the value to serialize, return `undefined` to skip serialization. `undefined` may also be used to avoid circular references.
 **/
serialize: (o: any) => any | undefined

In the updated contract, the user just returns the new value or current value.

Add a README

Add a README and be sure to mention that this is a fork.

Support transforming AST prior to serialization

It should be possible to transform the AST syntax prior to serialization rather than relying purely on value-level serialization customization.

This would be useful for removing syntax added by Functionless's TS transformers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.