Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
as-variant
Advanced tools
Supports any builtin types like i32, bool, string and any custom classes (managed and unmanaged).
import { Variant } from 'as-variant/assembly'
// before 0.20.x
// import { Variant } from 'as-variant'
class Foo { }
let vNum = Variant.from(123) // stored as i32
let vStr = Variant.from('hello') // stored as string
let vFoo = Variant.from(new Foo) // stored as Foo reference
vNum.set(2.0) // now stored as f64
assert(vNum.is<f64>()) // ok
assert(!vStr.is<f64>()) // ok
assert(vStr.is<string>()) // ok
assert(vFoo.is<Foo>()) // ok
assert(vNum.id != vStr.id) // compare dynamic IDs.
assert(vFoo.id == Variant.idof<Foo>())
let valF64 = vNum.get<f64>() // safely extract value
let willFail = vNum.get<string>() // will throw exception!
let vNum = Variant.from(123)
// `getUnchecked` skips all checks. It may be danger.
assert(vNum.getUnchecked<i32>() == 123)
const dict = new Map<string, Variant>()
dict.set('str', Variant.from('hello'))
dict.set('num', Variant.from(124.0))
dict.set('arr', Variant.from([1, 2, 3]))
assert(dict.get('arr').get<i32[]>()[2] == 3)
// or
assert(dict['arr'].get<i32[]>()[2] == 3)
which equivalent to JavaScript:
const dict = {
str: 'hello',
num: 124.0,
}
dict.arr = [1, 2, 3]
assert(dict.arr[2] == 3)
FAQs
Variant data type for AssemblyScript.
The npm package as-variant receives a total of 1,227 weekly downloads. As such, as-variant popularity was classified as popular.
We found that as-variant demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.