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

@meteor-it/utils

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@meteor-it/utils - npm Package Compare versions

Comparing version 1.0.0 to 1.2.2

AUTHORS.MD

133

index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const stream_1 = require("stream");
function firstUppercase(str) {

@@ -94,14 +94,3 @@ return str.substr(0, 1).toUpperCase() + str.substr(1);

function fixLength(string, length, insertPre = false, symbol = ' ') {
if (string.length < length) {
while (string.length < length) {
string = insertPre ? symbol + string : string + symbol;
}
}
else if (string.length > length) {
try {
string = string.match(insertPre ? new RegExp(`.*(.{${length}})`) : new RegExp(`(.{${length}})`))[0];
}
catch (e) { }
}
return string;
return insertPre ? string.padStart(length, symbol) : string.padEnd(length, symbol);
}

@@ -128,2 +117,120 @@ exports.fixLength = fixLength;

exports.arrayKVObject = arrayKVObject;
function sleep(time) {
return new Promise((res) => {
setTimeout(res, time);
});
}
exports.sleep = sleep;
function asyncEach(iterable, cb) {
let waitings = [];
iterable.forEach(iter => {
waitings.push(cb(iter));
});
return Promise.all(waitings);
}
exports.asyncEach = asyncEach;
function cb2promise(cbFunction) {
return (...args) => {
return new Promise((res, rej) => {
cbFunction(...args, (err, result) => {
if (err)
return rej(err);
res(result);
});
});
};
}
exports.cb2promise = cb2promise;
function hashCode(s) {
let hash = 0;
if (s.length === 0)
return hash;
for (let i = 0; i < s.length; i++) {
let character = s.charCodeAt(i);
hash = ((hash << 5) - hash) + character;
hash = hash & hash;
}
return hash;
}
exports.hashCode = hashCode;
function djb2Code(str) {
let hash = 5381;
for (let i = 0; i < str.length; i++) {
let char = str.charCodeAt(i);
hash = ((hash << 5) + hash) + char;
}
return hash;
}
exports.djb2Code = djb2Code;
function sdbmCode(str) {
let hash = 0;
for (let i = 0; i < str.length; i++) {
let char = str.charCodeAt(i);
hash = char + (hash << 6) + (hash << 16) - hash;
}
return hash;
}
exports.sdbmCode = sdbmCode;
function loseCode(str) {
let hash = 0;
for (let i = 0; i < str.length; i++) {
hash += str.charCodeAt(i);
}
return hash;
}
exports.loseCode = loseCode;
function encodeHtmlSpecials(str) {
let i = str.length;
let aRet = [];
while (i--) {
let iC = str[i].charCodeAt();
if (iC < 65 || iC > 127 || (iC > 90 && iC < 97)) {
aRet[i] = '&#' + iC + ';';
}
else {
aRet[i] = str[i];
}
}
return aRet.join('');
}
exports.encodeHtmlSpecials = encodeHtmlSpecials;
function createReadStream(object, options = {}) {
return new MultiStream(object, options);
}
exports.createReadStream = createReadStream;
function readStream(stream) {
return new Promise((res, rej) => {
const bufs = [];
stream.on('data', d => {
bufs.push(d);
});
stream.on('end', () => {
let buf = Buffer.concat(bufs);
res(buf);
});
stream.on('error', rej);
});
}
exports.readStream = readStream;
class MultiStream extends stream_1.Readable {
constructor(object, options = {}) {
if (object instanceof Buffer || typeof object === 'string') {
super({
highWaterMark: options.highWaterMark,
encoding: options.encoding
});
}
else {
super({
objectMode: true
});
}
this._object = object;
}
_read() {
this.push(this._object);
this._object = null;
}
}
exports.MultiStream = MultiStream;
//# sourceMappingURL=index.js.map

30

package.json
{
"name": "@meteor-it/utils",
"version": "1.0.0",
"description": "Utils",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Creeplays/utils.git"
},
"keywords": [
"utils"
],
"author": "f6cf",
"license": "MIT",
"bugs": {
"url": "https://github.com/Creeplays/utils/issues"
},
"homepage": "https://github.com/Creeplays/utils#readme"
"name": "@meteor-it/utils",
"version": "1.2.2",
"description": "Many useful utils",
"main": "index.js",
"keywords": [
"meteor-it",
"utils"
],
"author": "Yaroslaw Bolyukin <iam@f6cf.pw> (http://f6cf.pw/)",
"license": "MIT"
}

Sorry, the diff of this file is not supported yet

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