tryor

WebJar for tryor

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

tryor
Last Version

Last Version

0.1.2
Release Date

Release Date

Type

Type

jar
Description

Description

tryor
WebJar for tryor
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/olov/tryor

Download tryor

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/tryor/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>tryor</artifactId>
    <version>0.1.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/tryor/
implementation 'org.webjars.npm:tryor:0.1.2'
// https://jarcasting.com/artifacts/org.webjars.npm/tryor/
implementation ("org.webjars.npm:tryor:0.1.2")
'org.webjars.npm:tryor:jar:0.1.2'
<dependency org="org.webjars.npm" name="tryor" rev="0.1.2">
  <artifact name="tryor" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='tryor', version='0.1.2')
)
libraryDependencies += "org.webjars.npm" % "tryor" % "0.1.2"
[org.webjars.npm/tryor "0.1.2"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

tryor.js

Give it a function and a default value. tryor will give you back the return value of the function or, in case the function threw an exception, the default value. Works in node and browsers.

Usage

    // do this
    var config = tryor(function() {
        return JSON.parse(userProvidedConfigString);
    }, {});

    // instead of
    var config; // or var config = {}; and empty catch
    try {
        config = JSON.parse(userProvidedConfigString);
    } catch (e) {
        config = {};
    }

Works extra well with ES6-style const variables.

Installation

Node

Install using npm

npm install tryor
var tryor = require("tryor");

Browser

Clone the repo and include it in a script tag

git clone https://github.com/olov/tryor.git
<script src="tryor/tryor.js"></script>

Versions

Version
0.1.2