
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Statically typed Vect
$ npm i flow-vect
// @flow
import {
createVect,
push,
unshift,
shift,
head,
append,
index,
indexOf,
type Vect,
type GetLength,
type IsEmpty,
type IsNotEmpty
} from 'flow-vect'
const vect = createVect() // Vect<0, string> (type inferred from usage)
// or
// createVect<string>()
// createVect('str')
const vect1 = push('foo', vect) // Vect<1, string>
const vect2 = push('bar', vect1) // Vect<2, string>
type Length = GetLength<typeof vect2>
;(2: Length)
// $ExpectError
;(3: Length) // error
;(true: IsNotEmpty<typeof vect2>)
// $ExpectError
;(true: IsEmpty<typeof vect2>) // error
;(true: IsEmpty<typeof vect>)
;(false: IsEmpty<typeof vect1>)
console.log(vect2) //=> Vect
const vect22: Vect<2, string> = vect2
const [ value, vect11 ] = shift(vect22)
console.log(value) //=> 'foo'
;(1: GetLength<typeof vect11>)
;(vect11: Vect<1, string>)
const vect3 = unshift('abc', vect22)
;(vect3: Vect<3, string>)
const el = head(vect3)
;(el: string)
console.log(el) //=> 'abc'
const vect50 = append(vect22, (vect3: Vect<3, string>))
;(vect50: Vect<5, string>)
const el0 = index(1, vect22)
;(el0: string)
console.log('index', el0) //=> 'bar'
;(indexOf('bar', vect22): number | void)
function sum2 (vect: Vect<2, number>): number {
const [x, xs] = shift(vect)
const [y] = shift(xs)
return x + y
}
See also index.test.js.
createVect
push
pop
unshift
shift
head
last
append
index
indexOf
equals
isVect
Vect<N, T>
GetLength<V>
IsEmpty<V>
IsNotEmpty<V>
IsVect<V>
FAQs
Statically typed Vect
We found that flow-vect 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.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.