Extensions - leacode/SwiftWings GitHub Wiki
SwiftWings ships a suite of lightweight Foundation extensions. This reference lists every extension module, the files that define it, and the key behaviors they provide. File paths refer to the Sources/Extensions/Foundation and Tests/Extensions directories so you can jump straight into the implementation or accompanying tests.
Detailed write-ups for each namespace now live under
Docs/extensions/…. Use the quick links below to jump directly into a specific section.
Array (details)
-
Source:
Sources/Extensions/Foundation/Array -
Tests:
Tests/Extensions/Array -
Highlights:
-
Array+Data.swift: ExposesArray<UInt8>.datato bridge toDatain a single call. -
Array+Subscript.swift: Adds the safesubscript(guard:)accessor plusreduct(_:), a convenience reducer that operates only when the collection is non-empty.
-
Bundle (details)
-
Source:
Sources/Extensions/Foundation/Bundle/Bundle+Extensions.swift -
Tests:
Tests/Extensions/Bundle -
Highlights:
appVersionreadsCFBundleShortVersionStringdirectly from the bundle’sinfoDictionary, matching the behavior exercised inBundle+ExtensionsTests.
Codable (details)
-
Source:
Sources/Extensions/Foundation/Codable/Codable+JSON.swift -
Tests:
Tests/Extensions/Codable -
Highlights:
-
Encodable.jsonStringusesJSONEncoder+ UTF-8 conversion for lightweight logging. -
Encodable.dictionary()re-encodes the value and deserializes it into[String: Any]for quick dictionary views.
-
Data & Mime Types (details)
-
Source:
Sources/Extensions/Foundation/Data -
Tests:
Tests/Extensions/Data -
Highlights:
-
Data+Extensions.swift: Addsbytesto expose[UInt8]for crypto and parsing helpers. -
Data+PrettyJSON.swift: ProvidesprettyJSONString, conversion from JSON fragments toData, plus array/dictionary convenience factories. -
Data+MimeType.swift&MimeType.swift: Detect dozens of file signatures (audio/image/application/etc.) by inspecting magic numbers. Test fixtures inTests/Extensions/Data/Data+MimeTypeTests.swiftassert every signature.
-
Date (details)
-
Source:
Sources/Extensions/Foundation/Date -
Tests:
Tests/Extensions/Date -
Highlights:
-
Date+Extensions.swift: Calendar helpers such ascurrentTimeMillis,isToday,isInNextWeek, previous/next weekday lookups, and rolling by days/months/years. -
Date+Components.swift: Shorthand computed properties (year,month,weekday, etc.) that defer toCalendar.current. -
Date+Utilities.swift: Adds start/end-of-component calculations, comparisons (isSame,isBetween), range helpers (clamped), arithmetic (advanced), and DST-safe interval/distance helpers. -
Date+TimeZone.swift: User-facing helpers to convert a wall-clock time between zones, format using a pinnedDateFormatter, and extract components for a suppliedTimeZone. -
Date+Intervals.swift: Convenience wrappers overCalendar.dateInterval(of:for:)anddateComponents(_:from:to:)so you can request DST-awareDateIntervals or structured differences with a single call.
-
TimeZone (details)
-
Source:
Sources/Extensions/Foundation/TimeZone/TimeZone+Extensions.swift -
Tests:
Tests/Extensions/Date/Date+TimeZoneTests.swift -
Highlights: Adds
TimeZone.utc, readable offset strings (e.g.+05:30), and DST helpers (isDaylightSavingActive,upcomingDaylightSavingTransition).
Double (details)
-
Source:
Sources/Extensions/Foundation/Double -
Tests:
Tests/Extensions/Double -
Highlights:
-
Double+Extensions.swift: AddstoString()with%.02fformatting andBinaryFloatingPoint.toInt()for lossless conversions. -
Double+ChineseCurrency.swift: Spells monetary amounts in formal Chinese numerals (chineseMoneySpell).
-
Int (details)
-
Source:
Sources/Extensions/Foundation/Int -
Tests:
Tests/Extensions/Int -
Highlights:
-
Int.bytes(_:)exposes big-endian byte arrays.halfsafely divides values with guardrails against-1...1. -
BinaryIntegertraits for Simplified/Traditional Chinese spell-outs, parity checks, and conversions toDouble/String. -
Int+ChineseCurrency.swift: Bridges toDouble.chineseMoneySpellfor integer-friendly usage.
-
Mirror (details)
-
Source:
Sources/Extensions/Foundation/Mirror/Mirror+Reflection.swift -
Tests:
Tests/Extensions/Mirror -
Highlights:
Mirror.reflectPropertiesperforms shallow or recursive reflection and invokes a closure for every child matching a type, mirroring the tests inMirror+ReflectionTests.
NSNumber (details)
-
Source:
Sources/Extensions/Foundation/NSNumber/NSNumber+Display.swift -
Tests:
Tests/Extensions/NSNumber - Highlights: Placeholder file reserved for NSNumber display helpers. (Currently unused; documented so future additions have a canonical doc entry.)
NSObject (details)
-
Source:
Sources/Extensions/Foundation/NSObject/NSObject+Name.swift -
Tests:
Tests/Extensions/NSObject -
Highlights: Adds
className(type and instance) on non-macOS platforms because macOS already exposes these selectors. Tests assert portable behavior on all supported OSes.
Optional (details)
-
Source:
Sources/Extensions/Foundation/Optional/Optional+Transform.swift -
Tests:
Tests/Extensions/Optional -
Highlights: Introduces the
???operator, which mirrors??but always yields aStringby describing the wrapped value or falling back to a lazily-evaluated default.
Range (details)
-
Source:
Sources/Extensions/Foundation/Range/Range+Extensions.swift -
Tests:
Tests/Extensions/Range - Highlights: Reserved for future range helpers. (No public APIs today.)
URL (details)
-
Source:
Sources/Extensions/Foundation/URL/URL+Query.swift -
Tests:
Tests/Extensions/URL/URL+QueryTests.swift -
Highlights:
-
queryParameterssurfaces URL query items as a dictionary, mirroring SwifterSwift's approach to coalesce duplicate keys. -
mergingQueryParameters(_:replaceExisting:)merges, replaces, or removes query keys in one pass, inspired by community discussions on URLComponents usage. -
removingQueryParameters(_:)removes specific query keys without mutating other items.
-
Sequence (details)
-
Source:
Sources/Extensions/Foundation/Sequence/Sequence+Extensions.swift -
Tests:
Tests/Extensions/Sequence -
Highlights: Adds
Sequence.unique()for hashable elements while preserving order viaSetmembership tracking.
String (details)
-
Source:
Sources/Extensions/Foundation/String -
Tests:
Tests/Extensions/String -
Highlights:
-
String+Extensions.swift: JSON parsing helpers (asDict,asArray),asURL, localization, and JSON convenience initializers mirroring the data helpers. -
String+Emoji.swift: Unicode scalar analysis for emoji detection pluscontainsOnlyEmoji,trimmingEmojis, etc. -
String+File.swift: ExtractsfileExtensionfrom filenames. -
String+MD5.swift: Pure-Swift MD5 implementation that powers the.md5computed property. -
String+Modify.swift: Pluralization rules, vowel/consonant lists, dictionary-driven replacements, trimming utilities, and capitalization helpers. -
String+Subscript.swift: Safe slicing APIs for every Swift range flavor (ClosedRange,Range,PartialRangeFrom, etc.). -
String+Validation.swift: Validation suite for phone numbers, links, email, bank cards (Luhn), JSON, UUIDs, digits/letters, condensed whitespace, etc.
-
(Already covered under Bundle.)
If you add another extension folder, update this document and the associated tests so the catalogue stays accurate.