@ridi/parser-core
Advanced tools
Comparing version 0.5.4 to 0.5.5
@@ -33,4 +33,2 @@ 'use strict'; | ||
var _stringContains2 = _interopRequireDefault(_stringContains); | ||
var _validateOptions = require('./validateOptions'); | ||
@@ -109,3 +107,3 @@ | ||
var checkDataType = function checkDataType(data) { | ||
if (!(0, _stringContains2.default)(['Buffer', 'Uint8Array', 'Array'], (0, _typecheck.getType)(data))) { | ||
if (!(0, _stringContains.stringContains)(['Buffer', 'Uint8Array', 'Array'], (0, _typecheck.getType)(data))) { | ||
throw (0, _errors.createError)(_errors2.default.EINVAL, 'bytes type', 'reason', 'require Buffer or Uint8Array or Array'); | ||
@@ -121,3 +119,3 @@ } | ||
throw (0, _errors.createError)(_errors2.default.EREQPRM, 'mode'); | ||
} else if (!(0, _typecheck.isObject)(mode) || !(0, _stringContains2.default)((0, _keys2.default)(Modes), mode.name)) { | ||
} else if (!(0, _typecheck.isObject)(mode) || !(0, _stringContains.stringContains)((0, _keys2.default)(Modes), mode.name)) { | ||
throw (0, _errors.createError)(_errors2.default.EINVAL, 'mode', 'mode', 'use Modes'); | ||
@@ -124,0 +122,0 @@ } |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.openZip = exports.validateOptions = exports.isUrl = exports.isString = exports.isObject = exports.isFunc = exports.isExists = exports.isBool = exports.isArray = exports.getType = exports.stringContains = exports.readEntries = exports.getPathes = exports.safePathJoin = exports.safePath = exports.safeDirname = exports.Parser = exports.parseBool = exports.mergeObjects = exports.LogLevel = exports.Logger = exports.mustOverride = exports.createError = exports.Errors = exports.CryptoProvider = exports.AesCryptor = exports.writeCacheFile = exports.readCacheFile = exports.removeAllCacheFiles = exports.removeCacheFile = exports.getCachePath = undefined; | ||
exports.openZip = exports.validateOptions = exports.isUrl = exports.isString = exports.isObject = exports.isFunc = exports.isExists = exports.isBool = exports.isArray = exports.getType = exports.stringContains = exports.MatchOption = exports.readEntries = exports.getPathes = exports.safePathJoin = exports.safePath = exports.safeDirname = exports.Parser = exports.parseBool = exports.mergeObjects = exports.LogLevel = exports.Logger = exports.mustOverride = exports.createError = exports.Errors = exports.CryptoProvider = exports.AesCryptor = exports.writeCacheFile = exports.readCacheFile = exports.removeAllCacheFiles = exports.removeCacheFile = exports.getCachePath = undefined; | ||
@@ -47,4 +47,2 @@ var _cacheFile = require('./cacheFile'); | ||
var _stringContains2 = _interopRequireDefault(_stringContains); | ||
var _typecheck = require('./typecheck'); | ||
@@ -82,3 +80,4 @@ | ||
exports.readEntries = _readEntries2.default; | ||
exports.stringContains = _stringContains2.default; | ||
exports.MatchOption = _stringContains.MatchOption; | ||
exports.stringContains = _stringContains.stringContains; | ||
exports.getType = _typecheck.getType; | ||
@@ -85,0 +84,0 @@ exports.isArray = _typecheck.isArray; |
@@ -40,4 +40,2 @@ 'use strict'; | ||
var _stringContains2 = _interopRequireDefault(_stringContains); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -83,3 +81,3 @@ | ||
set: function set(level) { | ||
this._logLevel = (0, _stringContains2.default)((0, _values2.default)(LogLevel), level) ? level : this.logLevel; | ||
this._logLevel = (0, _stringContains.stringContains)((0, _values2.default)(LogLevel), level) ? level : this.logLevel; | ||
} | ||
@@ -93,3 +91,3 @@ }]); | ||
this.namespace = namespace || Logger.name; | ||
this._logLevel = (0, _stringContains2.default)((0, _values2.default)(LogLevel), logLevel) ? logLevel : LogLevel.WARN; | ||
this._logLevel = (0, _stringContains.stringContains)((0, _values2.default)(LogLevel), logLevel) ? logLevel : LogLevel.WARN; | ||
this._firstTime = null; | ||
@@ -96,0 +94,0 @@ } |
@@ -12,6 +12,2 @@ 'use strict'; | ||
var _stringContains2 = _interopRequireDefault(_stringContains); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function parseBool(any) { | ||
@@ -21,4 +17,4 @@ if ((0, _typecheck.isBool)(any)) { | ||
} | ||
return (0, _typecheck.isString)(any) ? (0, _stringContains2.default)(['true', 't', '1', 'yes', 'y'], any) : false; | ||
return (0, _typecheck.isString)(any) ? (0, _stringContains.stringContains)(['true', 't', '1', 'yes', 'y'], any) : false; | ||
} | ||
module.exports = exports.default; |
@@ -6,12 +6,48 @@ 'use strict'; | ||
}); | ||
exports.default = stringContains; | ||
exports.stringContains = exports.MatchOption = undefined; | ||
var _typecheck = require('./typecheck'); | ||
var MatchOption = { | ||
MATCHING: 0, | ||
CONTAINING: 1, | ||
STARTSWITH: 2, | ||
ENDSWITH: 3 | ||
}; | ||
function stringContains() { | ||
var array = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; | ||
var string = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | ||
var matchOption = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : MatchOption.MATCHING; | ||
var lString = string.toLowerCase(); | ||
return array.map(function (item) { | ||
return item.toLowerCase(); | ||
}).includes(lString); | ||
return (0, _typecheck.isExists)(array.find(function (item) { | ||
var lItem = item.toLowerCase(); | ||
switch (matchOption) { | ||
case MatchOption.CONTAINING: | ||
if (lItem.indexOf(lString) >= 0) { | ||
return true; | ||
} | ||
break; | ||
case MatchOption.STARTSWITH: | ||
if (lItem.startsWith(lString)) { | ||
return true; | ||
} | ||
break; | ||
case MatchOption.ENDSWITH: | ||
if (lItem.endsWith(lString)) { | ||
return true; | ||
} | ||
break; | ||
default: | ||
if (lItem === lString) { | ||
return true; | ||
} | ||
break; | ||
} | ||
return false; | ||
})); | ||
} | ||
module.exports = exports.default; | ||
exports.MatchOption = MatchOption; | ||
exports.stringContains = stringContains; |
{ | ||
"name": "@ridi/parser-core", | ||
"version": "0.5.4", | ||
"version": "0.5.5", | ||
"description": "Utilities for parsers", | ||
@@ -5,0 +5,0 @@ "author": { |
73029
1830