GithubHelp home page GithubHelp logo

xunnamius / toss-expression Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 17 KB

A tiny ponyfill for @babel/plugin-proposal-throw-expressions, the syntax from which TypeScript and VS Code do not (yet) support

Home Page: https://www.npmjs.com/package/toss-expression

License: MIT License

JavaScript 100.00%
babel proposal throw expression expressions toss statement typescript invalid support

toss-expression's Introduction

Black Lives Matter! Maintenance status Last commit timestamp Open issues Pull requests codecov Source license NPM version semantic-release

toss-expression

While Babel supports throw expressions via plugins, TypeScript and VS Code do not (yet). Hence this five line ponyfill takes the place of the currently-unavailable @babel/plugin-proposal-throw-expressions syntax.

// Though the following is supported by Babel, VS Code/TypeScript will complain
const userToken = secureRequest() || throw new SecureAccessError('badness occurred');

// No errors
const userToken = secureRequest() || toss(new SecureAccessError('badness occurred'));

Installation and Usage

npm install toss-expression
// ESM
import { toss } from 'toss-expression';
console.log(successMessage() || toss('log operation failed'));
// CJS
const { toss } = require('toss-expression');
console.log(successMessage() || toss('log operation failed'));

Documentation

Further documentation can be found under docs/.

Contributing and Support

New issues and pull requests are always welcome and greatly appreciated! ๐Ÿคฉ Just as well, you can star ๐ŸŒŸ this project to let me know you found it useful! โœŠ๐Ÿฟ Thank you!

See CONTRIBUTING.md and SUPPORT.md for more information.

toss-expression's People

Contributors

xunnamius avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

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.