Comparing version 3.5.15 to 3.5.16
@@ -5,2 +5,8 @@ # Changelog | ||
## [3.5.16][] - 2021-10-10 | ||
- Add `Pool` method `isFree(item: object): boolean` | ||
- Add function `jsonParse(buffer: Buffer): object | null` | ||
- Add function `receiveBody(req: IncomingMessage): Promise<string | null>` | ||
## [3.5.15][] - 2021-09-23 | ||
@@ -122,3 +128,4 @@ | ||
[unreleased]: https://github.com/metarhia/metautil/compare/v3.5.15....HEAD | ||
[unreleased]: https://github.com/metarhia/metautil/compare/v3.5.16....HEAD | ||
[3.5.16]: https://github.com/metarhia/metautil/compare/v3.5.15...v3.5.16 | ||
[3.5.15]: https://github.com/metarhia/metautil/compare/v3.5.14...v3.5.15 | ||
@@ -125,0 +132,0 @@ [3.5.14]: https://github.com/metarhia/metautil/compare/v3.5.13...v3.5.14 |
@@ -67,4 +67,10 @@ 'use strict'; | ||
} | ||
isFree(item) { | ||
const index = this.items.indexOf(item); | ||
if (index < 0) return false; | ||
return this.free[index]; | ||
} | ||
} | ||
module.exports = { Pool }; |
@@ -294,2 +294,11 @@ 'use strict'; | ||
const jsonParse = (buffer) => { | ||
if (buffer.length === 0) return null; | ||
try { | ||
return JSON.parse(buffer); | ||
} catch { | ||
return null; | ||
} | ||
}; | ||
module.exports = { | ||
@@ -320,2 +329,3 @@ random, | ||
parseCookies, | ||
jsonParse, | ||
}; |
import { EventEmitter } from 'events'; | ||
import { IncomingMessage } from 'http'; | ||
@@ -103,4 +104,7 @@ export function cryptoRandom(): number; | ||
release(item: object): void; | ||
isFree(item: object): boolean; | ||
} | ||
export function fetch(url: string): Promise<string>; | ||
export function jsonParse(buffer: Buffer): object | null; | ||
export function receiveBody(req: IncomingMessage): Promise<Buffer | null>; |
@@ -9,3 +9,3 @@ 'use strict'; | ||
...require('./lib/async.js'), | ||
...require('./lib/fetch.js'), | ||
...require('./lib/network.js'), | ||
}; |
{ | ||
"name": "metautil", | ||
"version": "3.5.15", | ||
"version": "3.5.16", | ||
"author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>", | ||
@@ -41,3 +41,3 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@types/node": "^16.9.6", | ||
"@types/node": "^16.10.3", | ||
"eslint": "^7.32.0", | ||
@@ -44,0 +44,0 @@ "eslint-config-metarhia": "^7.0.1", |
@@ -46,2 +46,4 @@ # Metarhia utilities | ||
- `fetch(url: string): Promise<string>` | ||
- `jsonParse(buffer: Buffer): object | null` | ||
- `receiveBody(req: IncomingMessage): Promise<Buffer | null>` | ||
@@ -74,2 +76,3 @@ ## Crypto utilities | ||
- `release(item: object): void` | ||
- `isFree(item: object): boolean` | ||
@@ -76,0 +79,0 @@ ## License & Contributors |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30561
697
82