New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@hazae41/box

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hazae41/box - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

3

dist/types/mods/box/box.d.ts

@@ -9,3 +9,3 @@ import { Copiable, Copied } from '../copy/copy.js';

}
declare class Box<T extends Disposable> {
declare class Box<T extends Disposable> implements Disposable {
readonly inner: T;

@@ -18,2 +18,3 @@ moved: boolean;

[Symbol.dispose](): void;
static wrap<T extends Disposable>(inner: T): Box<T>;
/**

@@ -20,0 +21,0 @@ * Just get the inner value

@@ -8,4 +8,5 @@ /**

[Symbol.dispose](): void;
static wrap<T extends Disposable>(inner: T): Slot<T>;
}
export { Slot };
{
"type": "module",
"name": "@hazae41/box",
"version": "1.0.6",
"version": "1.0.7",
"description": "Rust-like Box for TypeScript",

@@ -6,0 +6,0 @@ "homepage": "https://github.com/hazae41/box",

@@ -45,1 +45,53 @@ # Box

```
## Rules
1. You can't pass a disposable object without wrapping it in a Box
2. You can't hold a disposable object without wrapping it in a Box
3. You can't hold a Box without owning it and disposing it after
4. You can't return a Box without unwrapping it
This means the typical object holding a Box looks like this
```tsx
import { Box } from "@hazae41/box"
class MyWrapper<T extends Disposable> {
private constructor(
/**
* Rule 2. hold as box
**/
readonly box: Box<T>
) {}
[Symbol.dispose]() {
/**
* Rule 3. dispose any box you hold
**/
this.box[Symbol.dispose]()
}
static create<T extends Disposable>(box: Box<T>) {
/**
* Rule 3. own any box you want to hold
**/
return new MyWrapper(box.move())
}
use() {
/**
* Rule 1. only pass as box
**/
something(this.box)
}
export(): T {
/**
* Rule 4. unwrap on return
**/
return this.box.unwrap()
}
}
```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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