New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

js-try

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-try

JS-try is a Javascript implementation of the try method from Rails for safe navigation

  • 0.9.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

JS-Try Build Status

JS-Try is a Javascript implementation of the try method from Rails for safe navigation.

Install

Yarn, NPM, or Bower
yarn add js-try

npm install js-try

bower install js-try
Rails / Bundler
# Gemfile
source 'https://rails-assets.org' do
  gem 'rails-assets-js-try'
end


# app/assets/javascripts/application.js
/*
 *= require js-try
*/

Usage

Require/Import
var Try = require('js-try');
// or
import { Try } from 'js-try';
Basic Examples
Try(undefined) == false;
Try(null) == false;
Try(false) == false;
Try(true) == true;
Try(0) == 0;
Try('') == '';
Try('foobar') == 'foobar';
Try([]) == [];
Try({}) == {};

false.try('length') == false;
true.try('length') == false;

''.try('length') == 0;
''.try('foobar') == false;
'foobar'.try('charAt', 3) == 'b';
''.try('badMethod').try('anotherBadMethod'); == false

var x = 0;
x.try('toString') == '0';
x.try('foobar') == false;

[].try('sort') == [];
[].try('foobar') == false;
[1,2,3].try(2) == 3;
[1,2,3].try(3) == false;

{}.try('toString') == "[object Object]";
{}.try('foobar') == false;
{foo: 'bar'}.try('foo') == 'bar';
{foo: 'bar'}.try('bar') == false;

Credits

Created by Weston Ganger - @westonganger

For any consulting or contract work please contact me via my company website: Solid Foundation Web Development

Similar Libraries Created By Me

Keywords

FAQs

Package last updated on 18 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc