An open API service indexing awesome lists of open source software.

https://github.com/lite-js/try2get

get any or get all return values
https://github.com/lite-js/try2get

Last synced: 11 months ago
JSON representation

get any or get all return values

Awesome Lists containing this project

README

          

try2get
=======

[![npm version](https://badge.fury.io/js/%40lite-js%2Ftry2get.svg)](https://badge.fury.io/js/%40lite-js%2Ftry2get) [![Build Status](https://travis-ci.org/lite-js/try2get.svg?branch=master)](https://travis-ci.org/lite-js/try2get)

get any or get all return values

## install

```shell
npm i @lite-js/try2get --save
```

## use cases

getting a supported XHR object [xhr.js](./example/xhr.js):

```javascript
const try2get = require('try2get');
const xhr = try2get.one(
() => new XMLHttpRequest(),
() => new ActiveXObject('MSXML2.XMLHTTP'),
() => new ActiveXObject('Microsoft.XMLHTTP')
);
```

listing all the supported features [built-ins.js](./example/built-ins.js):

```javascript
const try2get = require('../index');
const lang = require('zero-lang');

const features = try2get.all([
() => ArrayBuffer,
() => Atomics,
() => DataView,
() => Float32Array,
() => Float64Array,
() => JSON,
() => Map,
() => Math,
() => Promise,
() => Proxy,
() => Reflect,
() => SIMD,
() => Set,
() => Symbol,
() => Uint16Array,
() => Uint32Array,
() => Uint8Array,
() => Uint8ClampedArray,
() => WeakMap,
() => WeakSet,
]);

console.log(lang.map(features, feature => feature.toString()));
```