Skip to content

Commit

Permalink
s/prefix/leading/
Browse files Browse the repository at this point in the history
  • Loading branch information
djbe committed May 17, 2017
1 parent 20dcc18 commit d956026
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* [String filters](Documentation/filters-strings.md):
* `escapeReservedKeywords`: Escape keywods reserved in the Swift language, by wrapping them inside backticks so that the can be used as regular escape keywords in Swift code.
* `lowerFirstWord`
* `snakeToCamelCase`: Transforms text from snake_case to camelCase. By default it keeps prefix underscores, unless a single optional argument is set to "true", "no" or "0".
* `snakeToCamelCase`: Transforms text from snake_case to camelCase. By default it keeps leading underscores, unless a single optional argument is set to "true", "no" or "0".
* `camelToSnakeCase`: Transforms text from camelCase to snake_case. By default it converts to lower case, unless a single optional argument is set to "false", "no" or "0".
* `swiftIdentifier`: Transforms an arbitrary string into a valid Swift identifier (using only valid characters for a Swift identifier as defined in the Swift language reference)
* `titlecase`
Expand Down
6 changes: 3 additions & 3 deletions Sources/Filters+Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ extension Filters {
}

/// Converts snake_case to camelCase. Takes an optional Bool argument for removing any resulting
/// prefix '_' characters, which defaults to false
/// leading '_' characters, which defaults to false
///
/// - Parameters:
/// - value: the value to be processed
/// - arguments: the arguments to the function; expecting zero or one boolean argument
/// - Returns: the camel case string
/// - Throws: FilterError.invalidInputType if the value parameter isn't a string
static func snakeToCamelCase(_ value: Any?, arguments: [Any?]) throws -> Any? {
let stripPrefix = try Filters.parseBool(from: arguments, index: 0, required: false) ?? false
let stripLeading = try Filters.parseBool(from: arguments, index: 0, required: false) ?? false
guard let string = value as? String else { throw Filters.Error.invalidInputType }

let unprefixed: String
Expand All @@ -85,7 +85,7 @@ extension Filters {

// only if passed true, strip the prefix underscores
var prefixUnderscores = ""
if !stripPrefix {
if !stripLeading {
for scalar in string.unicodeScalars {
guard scalar == "_" else { break }
prefixUnderscores += "_"
Expand Down

0 comments on commit d956026

Please sign in to comment.