Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bitly

Package Overview
Dependencies
Maintainers
1
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bitly - npm Package Compare versions

Comparing version 5.0.3 to 5.0.4-beta-260

jsdoc.json

12

package.json

@@ -12,3 +12,3 @@ {

"homepage": "https://github.com/tanepiper/node-bitly",
"version": "5.0.3",
"version": "5.0.4-beta-260",
"author": {

@@ -54,9 +54,11 @@ "name": "Tane Piper",

"scripts": {
"prepublishOnly": "npm test && npm run build",
"test": "VCR_MODE=cache mocha-webpack --reporter list src/*.spec.js",
"build": "webpack --config=webpack.config.js"
"build": "webpack --config=webpack.config.js",
"docs": "jsdoc -c jsdoc.json -R README.md",
"lint": "eslint --config=./.eslintrc.json src/**.js"
},
"devDependencies": {
"@babel/preset-env": "^7.0.0-beta.4",
"@babel/preset-env": "^7.0.0-beta.5",
"babel-core": "^6.26.0",
"babel-eslint": "^8.0.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",

@@ -66,2 +68,4 @@ "babel-plugin-transform-runtime": "^6.23.0",

"eslint": "^4.10.0",
"jsdoc": "^3.5.5",
"minami": "^1.2.3",
"mocha": "^4.0.1",

@@ -68,0 +72,0 @@ "mocha-webpack": "^1.0.1",

const { doRequest, sortUrlsAndHash, generateUrl } = require('./lib');
/**
* The main Bitly constructor, takes the users login, api key and additional options
* @constructor
* This is the main Bitly module that returns an object of methods. You need to pass in your
* OAuth access token, as well as an optional config object. You are returned several helper
* methods, as well as access to a method to pass any bitly api request to.
*
* For information on the data returned from the API, see the docs at
* https://dev.bitly.com/api.html
*
* @module node-bitly
* @param {String} config,OAuth access token
* @param {Object=} config Optional config object
* @param {string} accessToken The access token, this from an OAuth session
* @param {object=} config Optional config object
* @returns {Bitly}
*/
module.exports = (accessToken, config) => {
/**
* Request to get clicks by day for a single short url, short hash or mixed array or items
* @param {String|Array} items The string or array of short urls and/or hashes to expand
* @return {Promise}
/**
* This is used to return the page title for a given Bitlink.
* @param {array<string>} items An array of short urls or hashes
* @return {object} The results of the request
*/
const info = async items =>
await doRequest({
accessToken,
method: 'info',
config,
data: sortUrlsAndHash(items),
});
/**
* Request to shorten one long url
* @param {String} longUrl The URL to be shortened
* @param {String=} domain The domain to use (optional)
* @return {Promise}
*/
const shorten = async longUrl =>
await doRequest({ accessToken, method: 'shorten', config, data: { longUrl } });
const info = async (items = []) =>
await doRequest({
accessToken,
method: 'info',
config,
data: sortUrlsAndHash(items)
});
/**
* Request to expand a single short url, short hash or mixed array or items
* @param {String|Array} items The string or array of short urls and/or hashes to expand
* @return {Promise}
*/
const expand = async items =>
await doRequest({ accessToken, method: 'expand', config, data: sortUrlsAndHash(items) });
/**
* Used to shorted a url
* @param {string} longUrl The URL to be shortened
* @return {object} The results of the request
*/
const shorten = async longUrl => await doRequest({ accessToken, method: 'shorten', config, data: { longUrl } });
/**
* Request to get clicks for a single short url, short hash or mixed array or items
* @param {String|Array} items The string or array of short urls and/or hashes to expand
* @return {Promise}
/**
* Request to expand urls and hashes
* @param {string|array<string>} items A string or array of strings of short urls and hashes.
* @return {object} The results of the request
*/
const expand = async items =>
await doRequest({ accessToken, method: 'expand', config, data: sortUrlsAndHash(items) });
/**
* Request to get clicks for urls and hashes
* @param {string|array<string>} items A string or array of strings of short urls and hashes.
* @return {object}
*/
const clicks = async items =>
await doRequest({ accessToken, method: 'clicks', config, data: sortUrlsAndHash(items) });
const clicks = async items =>
await doRequest({ accessToken, method: 'clicks', config, data: sortUrlsAndHash(items) });
/**
* Request to get clicks by minute for a single short url, short hash or mixed array or items
* @param {String|Array} items The string or array of short urls and/or hashes to expand
* @return {Promise}
/**
* Request to get clicks by minute for urls and hashes
* @param {string|array<string>} items A string or array of strings of short urls and hashes.
* @return {object}
*/
const clicksByMinute = async items =>
await doRequest({
accessToken,
method: 'clicks_by_minute',
config,
data: sortUrlsAndHash(items),
});
const clicksByMinute = async items =>
await doRequest({
accessToken,
method: 'clicks_by_minute',
config,
data: sortUrlsAndHash(items)
});
/**
* Request to get clicks by day for a single short url, short hash or mixed array or items
* @param {String|Array} items The string or array of short urls and/or hashes to expand
* @return {Promise}
/**
* Request to get clicks by day for urls and hashes
* @param {string|array<string>} items A string or array of strings of short urls and hashes.
* @return {object}
*/
const clicksByDay = async items =>
await doRequest({
accessToken,
method: 'clicks_by_day',
config,
data: sortUrlsAndHash(items),
});
const clicksByDay = async items =>
await doRequest({
accessToken,
method: 'clicks_by_day',
config,
data: sortUrlsAndHash(items)
});
/**
* Request to get look up an existing bitly link for a long url or array of urls
* @param {String|Array} links The string or array of long urls
* @return {Promise}
/**
* Lookup a single url
* @param {string} uri The uri to look up
* @return {object}
*/
const lookup = async items =>
await doRequest({
accessToken,
method: 'lookup',
config,
data: { url: items },
});
const lookup = async uri =>
await doRequest({
accessToken,
method: 'lookup',
config,
data: { url: uri }
});
/**
* Request the informations on all referrers for a short url. This function only
* accepts one url (as per the limit of the bitly API)
* @param {String} link The link be checked
* @return {Promise}
/**
* Request referrers for a single url
* @param {string} uri The uri to look up
* @return {object}
*/
const referrers = async item =>
await doRequest({
accessToken,
method: 'referrers',
config,
data: sortUrlsAndHash([item]),
});
const referrers = async item =>
await doRequest({
accessToken,
method: 'referrers',
config,
data: sortUrlsAndHash([item])
});
/**
* Request the informations on all countries for a short url. This function only
* accepts one url (as per the limit of the bitly API)
* @param {String} link The link be checked
* @return {Promise}
/**
* Request countries for a single url
* @param {string} uri The uri to look up
* @return {object}
*/
const countries = async item =>
await doRequest({
accessToken,
method: 'countries',
config,
data: sortUrlsAndHash([item]),
});
const countries = async item =>
await doRequest({
accessToken,
method: 'countries',
config,
data: sortUrlsAndHash([item])
});
return {
shorten,
expand,
clicks,
clicksByMinute,
clicksByDay,
lookup,
info,
referrers,
countries,
doRequest,
sortUrlsAndHash,
generateUrl,
};
return {
shorten,
expand,
clicks,
clicksByMinute,
clicksByDay,
lookup,
info,
referrers,
countries,
doRequest,
sortUrlsAndHash,
generateUrl
};
};
/**
* Bitly object definition
* @typedef {object} Bitly
* @property {Function} shorten Function that takes a url and shortens it. Accepts valid URL.
* @property {Function} expends Function that gets long urls for short urls. Accepts string or array of strings.
* @property {Function} clicks Function that gets the number of clicks of short urls. Accepts string or array of strings.
* @property {Function} clicksByMinute Function that gets the number of clicks by minute for short urls. Accepts string or array of strings.
* @property {Function} clicksByDay Function that gets the number of clicks by day for short urls. Accepts string or array of strings.
* @property {Function} lookup Function that takes a url looks up data. Accepts valid URL.
* @property {Function} info Function that takes a url and gets info. Accepts valid URL.
* @property {Function} referrers Function that gets referrers for urls. Accepts valid URL.
* @property {Function} countries Function that gets click by countries for urls. Accepts valid URL.
*/

@@ -28,3 +28,3 @@ require('sepia');

it('should expand a url and hash', async () => {
const result = await bitly.expand([EXAMPLE_URL, EXAMPLE_URL_HASH]);
const result = await bitly.expand([EXAMPLE_URL_BITLY, EXAMPLE_URL_HASH]);
const { data } = result;

@@ -37,3 +37,3 @@ expect(data.expand.length).to.equal(2);

it('should get click numbers for url', async () => {
const result = await bitly.clicks(EXAMPLE_URL);
const result = await bitly.clicks(EXAMPLE_URL_BITLY);
const { data } = result;

@@ -51,3 +51,3 @@ expect(data).to.have.property('clicks');

it('should get click numbers for url', async () => {
const result = await bitly.clicksByMinute(EXAMPLE_URL);
const result = await bitly.clicksByMinute(EXAMPLE_URL_BITLY);
const { data } = result;

@@ -73,3 +73,3 @@ expect(data).to.have.property('clicks_by_minute');

it('should get info for url', async () => {
const result = await bitly.info(EXAMPLE_URL);
const result = await bitly.info(EXAMPLE_URL_BITLY);
const { data } = result;

@@ -76,0 +76,0 @@ expect(data).to.have.property('info');

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