Skip to content

Commit d93b214

Browse files
StartAutomatingStartAutomating
authored andcommitted
feat: Language.Functions/Templates.Unique/Distinct ( Fixes #940 )
1 parent ceffa0b commit d93b214

1 file changed

Lines changed: 63 additions & 1 deletion

File tree

PipeScript.types.ps1xml

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2121,6 +2121,10 @@ return $false
21212121
<Type>
21222122
<Name>Language.Functions</Name>
21232123
<Members>
2124+
<AliasProperty>
2125+
<Name>Distinct</Name>
2126+
<ReferencedMemberName>Unique</ReferencedMemberName>
2127+
</AliasProperty>
21242128
<ScriptProperty>
21252129
<Name>All</Name>
21262130
<GetScriptBlock>
@@ -2153,11 +2157,42 @@ return $false
21532157
}).Length
21542158
</GetScriptBlock>
21552159
</ScriptProperty>
2160+
<ScriptProperty>
2161+
<Name>Unique</Name>
2162+
<GetScriptBlock>
2163+
&lt;#
2164+
.SYNOPSIS
2165+
Gets unique Language Functions
2166+
.DESCRIPTION
2167+
Gets unique functions related to a language.
2168+
#&gt;
2169+
$distinctCommands = @{}
2170+
,@(foreach ($psProperty in $this.PSObject.properties) {
2171+
if ($psProperty -isnot [psnoteproperty]) { continue }
2172+
if ($psProperty.Value -isnot [Management.Automation.CommandInfo]) { continue }
2173+
if (
2174+
$psProperty.Value -is [Management.Automation.AliasInfo] -and
2175+
(
2176+
$distinctCommands[$psProperty.Value.ResolvedCommand] -or
2177+
$this.PSObject.Properties[$psProperty.Value.ResolvedCommand.Name]
2178+
)
2179+
) {
2180+
continue
2181+
}
2182+
$distinctCommands[$psProperty.Value] = $psProperty.Value
2183+
$psProperty.Value
2184+
})
2185+
</GetScriptBlock>
2186+
</ScriptProperty>
21562187
</Members>
21572188
</Type>
21582189
<Type>
21592190
<Name>Language.Templates</Name>
21602191
<Members>
2192+
<AliasProperty>
2193+
<Name>Distinct</Name>
2194+
<ReferencedMemberName>Unique</ReferencedMemberName>
2195+
</AliasProperty>
21612196
<ScriptProperty>
21622197
<Name>All</Name>
21632198
<GetScriptBlock>
@@ -2190,6 +2225,33 @@ return $false
21902225
}).Length
21912226
</GetScriptBlock>
21922227
</ScriptProperty>
2228+
<ScriptProperty>
2229+
<Name>Unique</Name>
2230+
<GetScriptBlock>
2231+
&lt;#
2232+
.SYNOPSIS
2233+
Gets unique Language Templates
2234+
.DESCRIPTION
2235+
Gets unique templates related to a language.
2236+
#&gt;
2237+
$distinctCommands = @{}
2238+
,@(foreach ($psProperty in $this.PSObject.properties) {
2239+
if ($psProperty -isnot [psnoteproperty]) { continue }
2240+
if ($psProperty.Value -isnot [Management.Automation.CommandInfo]) { continue }
2241+
if (
2242+
$psProperty.Value -is [Management.Automation.AliasInfo] -and
2243+
(
2244+
$distinctCommands[$psProperty.Value.ResolvedCommand] -or
2245+
$this.PSObject.Properties[$psProperty.Value.ResolvedCommand.Name]
2246+
)
2247+
) {
2248+
continue
2249+
}
2250+
$distinctCommands[$psProperty.Value] = $psProperty.Value
2251+
$psProperty.Value
2252+
})
2253+
</GetScriptBlock>
2254+
</ScriptProperty>
21932255
</Members>
21942256
</Type>
21952257
<Type>
@@ -3208,7 +3270,7 @@ Add-Member -InputObject $this -Force -MemberType NoteProperty -Name '.ExcludePat
32083270

32093271
A Language is defined a function named Language.NameOfLanguage.
32103272

3211-
PipeScript presently ships with 66 languages:
3273+
PipeScript presently ships with 68 languages:
32123274

32133275
* ADA
32143276
* Arduino

0 commit comments

Comments
 (0)