Cryptoticker Strongly Typed

in #utopian-io6 years ago (edited)

Screen Shot 2018-01-20 at 6.42.36 AM.png

What is the project about?


This is a rebased version of the Cryptoticker library created by codingdefined. Basically, this is a NPM library that can be used to fetch the prices of the cryptocurrencies for two websites right now:

Differences


An strongly typed version of a library is one that defines all the datatype that will be used in the whole library. One of the benefits of this is that can be used without using noImplicitAny in Typescript. For instance, if you import the original library in Typescript, the TS linter/compiler will complain that there is not Types for this library and you will be forced to use Any as datatype.

Another difference is code completion in any IDE thanks to the types definitions of the library. By having the types definition, the TS compiler will be able to read them and help the end user completing code as well as telling what datatype does this method accepts.

Lastly, unnecessary dependencies were removed to make the library lighter.

Roadmap


More endpoints and functions will be added accordingly. For instance, so far there are only 2 endpoints available for this library.

How To Install?


To install this library, you simple need to run the following command:

npm i cryptoticker-ts --save

Usage


Here are some examples of usage:

Javascript

var crypto = require('cryptoticker-ts');
crypto.getPrice('bitcoin').then(data => {
    console.log(data)
});
Output should be an array with the prices

TypeScript

import * as crypto from 'cryptoticker-ts';
crypto.getPrice('bitcoin').then(data => {
    console.log(data)
});
Output should be an array with the prices

AMD

define(function(require,exports,module) {
  var crypto = require('cryptoticker-ts');
});

Available Methods


price(crypto: string): Promise<Array>

where the argument crypto is the cryptocurrency that you want to query.

priceWCI(crypto: string, key?: string): Promise<Array>

where the argument crypto is the cryptocurrency that you want to query and the argument key is your API key for https://www.worldcoinindex.com/

Mocha Test


To ensure that everything is working fine, after building the project, you should run

npm test

And you can expect the following response:

Screen Shot 2018-01-20 at 6.19.55 AM.png

How To Contribute?


Contributions are always welcome in any of my repos. To contribute, you need to fork my repo, make your changes, run the npm run-script build to build the project, npm test to run the mocha test, push to your repo, and make a PR (pull request):

git clone https://github.com/<YOUR-USERNAME>/cryptoticker-ts
cd ./cryptoticker-ts
.....
..... make your changes
.....
npm run-script build
npm test
.....
..... if everything is working fine
.....
git add -A
git commit -m "the changes you made"
git push origin <YOUR-BRANCH>

Github proof


Screen Shot 2018-01-20 at 6.50.22 AM.png



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Hey @jaysermendez I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Coin Marketplace

STEEM 0.30
TRX 0.12
JST 0.034
BTC 63799.64
ETH 3130.40
USDT 1.00
SBD 3.97