attempt-x

WebJar for attempt-x

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

attempt-x
Last Version

Last Version

1.1.3
Release Date

Release Date

Type

Type

jar
Description

Description

attempt-x
WebJar for attempt-x
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/Xotic750/attempt-x

Download attempt-x

How to add to project

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

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.

Travis status Dependency status devDependency status npm version jsDelivr hits bettercodehub score Coverage Status

attempt-x

Invokes function, returning an object of the results.

module.exports(fn, [...args])Object

This method attempts to invoke the function, returning either the result or the caught error object. Any additional arguments are provided to the function when it's invoked.

Kind: Exported function
Returns: Object - Returns an object of the result.

Param Type Description
fn function The function to attempt.
[...args] * The arguments to invoke the function with.

Example

import attempt from 'attempt-x';

function thrower() {
  throw new Error('Threw');
}

attempt(thrower, 1, 2);
// {
//   threw: true,
//   value: // Error('Threw') object
// }

function sumArgs(a, b) {
  return a + b;
}

attempt(sumArgs, 1, 2);
// {
//   threw: false,
//   value: 3
// }

const thisArg = [];
function pusher(a, b) {
  return this.push(a, b);
}

attempt.call(thisArg, pusher, 1, 2);
// {
//   threw: false,
//   value: 2
// }
// thisArg => [1, 2];

Versions

Version
1.1.3