Socket
Socket
Sign inDemoInstall

metautil

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metautil - npm Package Compare versions

Comparing version 3.5.11 to 3.5.12

8

CHANGELOG.md

@@ -5,2 +5,7 @@ # Changelog

## [3.5.12][] - 2021-09-18
- Pool implementation with round-robian and exclusive item capture/release
- Move parsePath from impress
## [3.5.11][] - 2021-09-09

@@ -102,3 +107,4 @@

[unreleased]: https://github.com/metarhia/metautil/compare/v3.5.11....HEAD
[unreleased]: https://github.com/metarhia/metautil/compare/v3.5.12....HEAD
[3.5.12]: https://github.com/metarhia/metautil/compare/v3.5.11...v3.5.12
[3.5.11]: https://github.com/metarhia/metautil/compare/v3.5.10...v3.5.11

@@ -105,0 +111,0 @@ [3.5.10]: https://github.com/metarhia/metautil/compare/v3.5.9...v3.5.10

@@ -58,2 +58,9 @@ 'use strict';

const parsePath = (relPath) => {
const name = path.basename(relPath, '.js');
const names = relPath.split(path.sep);
names[names.length - 1] = name;
return names;
};
const between = (s, prefix, suffix) => {

@@ -319,2 +326,48 @@ let i = s.indexOf(prefix);

class Pool {
constructor() {
this.items = [];
this.free = [];
this.current = 0;
this.size = 0;
this.available = 0;
}
next() {
if (this.available === 0) return null;
let item = null;
let free = false;
do {
item = this.items[this.current];
free = this.free[this.current];
this.current++;
} while (!item && !free);
if (this.current === this.size) this.current = 0;
return item;
}
add(item) {
this.size++;
this.available++;
this.items.push(item);
this.free.push(true);
}
capture() {
const item = this.next();
if (!item) return null;
const index = this.current - 1;
this.free[index] = false;
this.available--;
return item;
}
release(item) {
const index = this.items.indexOf(item);
if (index < 0) throw new Error('Pool: release unexpected item');
this.free[index] = true;
this.available++;
}
}
module.exports = {

@@ -328,2 +381,3 @@ random,

fileExt,
parsePath,
between,

@@ -348,2 +402,3 @@ split,

delay,
Pool,
};

@@ -30,2 +30,3 @@ import { EventEmitter } from 'events';

export function fileExt(fileName: string): string;
export function parsePath(relPath: string): Array<string>;
export function between(s: string, prefix: string, suffix: string): string;

@@ -89,1 +90,14 @@ export function isFirstUpper(s: string): boolean;

}
export class Pool {
concurrency: number;
items: Array<object>;
free: Array<object>;
current: number;
size: number;
available: number;
next(): object | null;
add(item: object): void;
capture(): object | null;
release(item: object): void;
}

2

package.json
{
"name": "metautil",
"version": "3.5.11",
"version": "3.5.12",
"author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>",

@@ -5,0 +5,0 @@ "license": "MIT",

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