This directory and it's subdirectories contain syntax changes that enable common programming scenarios in PowerShell and PipeScript.
| DisplayName | Synopsis |
|---|---|
| NamespacedFunction | Namespaced functions |
| ArrowOperator | Arrow Operator |
| ConditionalKeyword | Conditional Keyword Expansion |
{
abstract function Point {
param(
[Alias('Left')]
[vbn()]
$X,
[Alias('Top')]
[vbn()]
$Y
)
}
}.Transpile() {
interface function AccessToken {
param(
[Parameter(ValueFromPipelineByPropertyName)]
[Alias('Bearer','PersonalAccessToken', 'PAT')]
[string]
$AccessToken
)
}
}.Transpile() {
partial function PartialExample {
process {
1
}
}
partial function PartialExample* {
process {
2
}
}
partial function PartialExample// {
process {
3
}
}
function PartialExample {
}
}.Transpile() $allTypes =
Invoke-PipeScript {
[AppDomain]::CurrentDomain.GetAssemblies() => $_.GetTypes()
}
$allTypes.Count # Should -BeGreaterThan 1kb
$allTypes # Should -BeOfType ([Type]) Invoke-PipeScript {
Get-Process -ID $PID => ($Name, $Id, $StartTime) => { "$Name [$ID] $StartTime"}
} # Should -Match "$pid" Invoke-PipeScript {
func => ($Name, $Id) { $Name, $Id}
} # Should -BeOfType ([ScriptBlock]) Invoke-PipeScript {
$n = 1
do {
$n = $n * 2
$n
break if (-not ($n % 16))
} while ($true)
} Import-PipeScript {
function Get-Primes([ValidateRange(2,64kb)][int]$UpTo) {
$KnownPrimes = new Collections.ArrayList @(2)
$SieveOfEratosthenes = new Collections.Generic.Dictionary[uint32,bool]
$n = 2
:nextNumber for (; $n++;) {
# Break if past our point of interest
break if ($n -ge $upTo)
# Skip if an even number
continue if (-not ($n -band 1))
# Check our sieve
continue if $SieveOfEratosthenes.ContainsKey($n)
# Determine half of the number
$halfN = $n /2
# If this is divisible by the known primes
foreach ($k in $knownPrimes) {
continue nextNumber if (($n % $k) -eq 0) {}
break if ($k -ge $halfN)
}
foreach ($k in $knownPrimes) {
$SieveOfEratosthenes[$n * $k] = $true
}
$null = $knownPrimes.Add($n)
}
$knownPrimes -le $UpTo
}
}