memory-allocator
Advanced tools
+21
| MIT License | ||
| Copyright (c) 2023 Warriors Life | ||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
+37
| # memory-allocator | ||
| A simple ArrayBuffer memory allocator for JS. | ||
| Not to be confused with the [`memory-pool`](https://www.npmjs.com/package/memory-pool) package, which removes the overhead of object creation by maintaining a pool of them and modifying their properties. | ||
| ## License | ||
| [MIT](LICENSE). | ||
| ## Contributing | ||
| Feel free to [open an issue](https://github.com/warriors-life/memory-allocator/issues/new) or [make a pull request](https://github.com/warriors-life/memory-allocator/pulls)! You can find contributing guidelines [here](CONTIBUTING.md) and as a start you can work on any issue labelled ["good first issue"](https://github.com/warriors-life/memory-allocator/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22). | ||
| # Documentation | ||
| The package exports `MemoryAllocator` class as default. | ||
| ## class MemoryAllocator | ||
| The main class. | ||
| ### constructor(bufferSize: number = 1024 ** 2) | ||
| `bufferSize` parameters controls minimal size of the new array buffers created by MemoryAllocator when it is impossible to allocate data in old buffers. | ||
| ### .addBuffer(size?: number >= bufferSize): ignore | ||
| Manually create a buffer of the specified size. | ||
| ### .allocate(size): MemoryRef | ||
| Allocate a slice of memory of the specified size. The resulting memory ref is returned. | ||
| ## class MemoryRef | ||
| Reference to a slice of memory. Note that underlying slice may be relocated during a manual defragmentation. | ||
| ### async .free(): void | ||
| Mark the reference as freed. It can no longer be used after that and the underlying memory may be redistributed. | ||
| ### .toDataView(): DataView | ||
| Returns a DataView of the underlying memory, which can be read and written to. | ||
| ### .toTypedArray(class?: Class\<? extends TypedArray\> = Uint8Array): class | ||
| Returns a typed array mapped to the underlying memory, which can be read and written to. |
+2
-2
| { | ||
| "name": "memory-allocator", | ||
| "author": "Warriors Life", | ||
| "version": "0.0.2", | ||
| "version": "0.0.3", | ||
| "description": "Simple ArrayBuffer memory allocator", | ||
| "license": "SEE LICENSE IN ../LICENSE", | ||
| "license": "MIT", | ||
| "type": "module", | ||
@@ -8,0 +8,0 @@ "exports": "./index.js", |
Misc. License Issues
LicenseA package's licensing information has fine-grained problems.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
Unidentified License
LicenseSomething that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
6512
78.36%7
40%0
-100%0
-100%1
-50%38
Infinity%