lightref
v1.0.4
Published
Pass by reference for primitive types.
Downloads
2
Readme
lightref
Pass primitive types to javascript functions, by reference.
Passed by value
let myVal = "hello"
testFunction(myVal);
function testFunction(val: string) {
val += " world";
}
console.log(myVal);
// Output: "hello"
Passed by reference
import { Deref, Ref} from "lightref";
const myRef = Ref<string>("hello");
testFunction(myRef);
function testFunction(ref: Ref<string>) {
ref.value += " world";
}
console.log(myRef.value);
// Output: "hello world"