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

abl-utils

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abl-utils - npm Package Compare versions

Comparing version 0.6.2 to 1.0.0

6

package.json
{
"name": "abl-utils",
"title": "ABL - utils",
"version": "0.6.2",
"version": "1.0.0",
"license": "MIT",

@@ -28,7 +28,5 @@ "description": "description",

"debug": "2.2.0",
"escape-string-regexp": "1.0.5",
"lodash": "4.8.2",
"moment-config-trejgun": "git://github.com/TrejGun/moment-config-trejgun.git#v0.0.4",
"qs": "6.1.0",
"rrule": "2.1.0"
"qs": "6.1.0"
},

@@ -35,0 +33,0 @@ "devDependencies": {

"use strict";
import crypto from "crypto";
import {getObject} from "abl-lang/build/index";
import configs from "./configs/config";
export function getType(variable) {

@@ -14,35 +14,13 @@ return Object.prototype.toString.call(variable);

export function getRandomString(length = 64, type = 3) {
const chars = [
"0123456789",
"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
];
const randomBytes = crypto.randomBytes(length);
const result = new Array(length);
let cursor = 0;
for (let i = 0; i < length; i++) {
cursor += randomBytes[i];
result[i] = chars[type][cursor % chars[type].length];
}
return result.join("");
export function formatUrl({protocol, hostname, port}) {
// url.format puts port 80 which we don't need
return `${protocol}://${hostname}${port === "80" ? "" : `:${port}`}`;
}
export function getRandomElementFromArray(array = []) {
return array[Math.floor(Math.random() * array.length)];
export function getServerUrl(env = process.env.NODE_ENV) {
return formatUrl(configs[env].server);
}
export function tpl(template, data) {
return template.replace(/(\$\{([^\{\}]+)\})/g, ($0, $1, $2) => getObject($2, data));
export function getIP(request) {
return request.get("CF-Connecting-IP") || request.ip;
}
export function toDollars(amount) {
return `$${(amount && amount / 100 || 0).toFixed(2)}`;
}
export function formatUrl({protocol, hostname, port}) {
// url.format puts port 80 which we dont need
return `${protocol}://${hostname}${port === "80" ? "" : `:${port}`}`;
}

@@ -5,10 +5,7 @@ "use strict";

import querystring from "querystring";
import {formatUrl} from "./misc";
import {getServerUrl} from "./misc";
import {makeError} from "./error";
import {translate} from "abl-lang";
import configs from "./configs/config";
const config = configs[process.env.NODE_ENV];
function _send(request, response) {

@@ -60,3 +57,3 @@ return (error) => {

const last = Math.ceil(count / request.query.pageSize);
const url = `${formatUrl(config.server)}${request.route.path}?`;
const url = `${getServerUrl()}${request.route.path}?`;

@@ -63,0 +60,0 @@ response.set("X-First-Page-Url", url + querystring.stringify({

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