Skip to content

Commit

Permalink
feat(strings): added uppercase and lowercase, closes #71
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed May 11, 2016
1 parent e199a82 commit 071c587
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 23 deletions.
29 changes: 19 additions & 10 deletions dist/check-more-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,23 @@ return /******/ (function(modules) { // webpackBootstrap
return isString(x) && Boolean(x)
}

/**
Checks if given string is already in upper case
@method upperCase
*/
function upperCase (x) {
return isString(x) && x.toUpperCase() === x
}

/**
Checks if given string is already in lower case
@method lowerCase
*/
function lowerCase (str) {
return isString(str) &&
str.toLowerCase() === str
}

var isArray = Array.isArray

function isObject (x) {
Expand Down Expand Up @@ -377,15 +394,6 @@ return /******/ (function(modules) { // webpackBootstrap
return typeof value === 'boolean'
}

/**
Checks if given string is already in lower case
@method lowerCase
*/
function lowerCase (str) {
return isString(str) &&
str.toLowerCase() === str
}

/**
Checks if given object has a property
@method has
Expand Down Expand Up @@ -464,7 +472,6 @@ return /******/ (function(modules) { // webpackBootstrap
intNumber: isInteger,
isArray: isArray,
length: curry2(hasLength),
lowerCase: lowerCase,
negative: negativeNumber,
negativeNumber: negativeNumber,
nulled: isNull,
Expand All @@ -478,6 +485,8 @@ return /******/ (function(modules) { // webpackBootstrap
string: isString,
unempty: unempty,
unemptyString: unemptyString,
upperCase: upperCase,
lowerCase: lowerCase,
validDate: validDate,
zero: zero
}
Expand Down
6 changes: 3 additions & 3 deletions dist/check-more-types.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions src/low-level-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,41 @@ describe('check-more-types low-level predicates', function () {
})
})

describe('check.lowerCase', function () {
it('is defined', function () {
la(check.fn(check.lowerCase))
})

/** @sample check/lowerCase */
it('check.lowerCase', function () {
la(check.lowerCase(''))
la(check.lowerCase(' '))
la(check.lowerCase('0123'))
la(check.lowerCase('abb foo'))
la(!check.lowerCase(0))
la(!check.lowerCase([]))
la(!check.lowerCase('Foo'))
})
})

describe('check.upperCase', function () {
it('is defined', function () {
la(check.fn(check.upperCase))
})

/** @sample check/upperCase */
it('check.upperCase', function () {
la(check.upperCase(''))
la(check.upperCase(' '))
la(check.upperCase('0123'))
la(check.upperCase('ABB FOO'))
la(!check.upperCase('abb foo'))
la(!check.lowerCase(0))
la(!check.lowerCase([]))
la(!check.lowerCase('Foo'))
})
})

describe('check.unemptyString', function () {
it('is defined', function () {
la(check.fn(check.unemptyString))
Expand Down
29 changes: 19 additions & 10 deletions src/low-level.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,23 @@ function unemptyString (x) {
return isString(x) && Boolean(x)
}

/**
Checks if given string is already in upper case
@method upperCase
*/
function upperCase (x) {
return isString(x) && x.toUpperCase() === x
}

/**
Checks if given string is already in lower case
@method lowerCase
*/
function lowerCase (str) {
return isString(str) &&
str.toLowerCase() === str
}

var isArray = Array.isArray

function isObject (x) {
Expand Down Expand Up @@ -133,15 +150,6 @@ function bool (value) {
return typeof value === 'boolean'
}

/**
Checks if given string is already in lower case
@method lowerCase
*/
function lowerCase (str) {
return isString(str) &&
str.toLowerCase() === str
}

/**
Checks if given object has a property
@method has
Expand Down Expand Up @@ -220,7 +228,6 @@ module.exports = {
intNumber: isInteger,
isArray: isArray,
length: curry2(hasLength),
lowerCase: lowerCase,
negative: negativeNumber,
negativeNumber: negativeNumber,
nulled: isNull,
Expand All @@ -234,6 +241,8 @@ module.exports = {
string: isString,
unempty: unempty,
unemptyString: unemptyString,
upperCase: upperCase,
lowerCase: lowerCase,
validDate: validDate,
zero: zero
}

0 comments on commit 071c587

Please sign in to comment.