zeelib
A small lib of FP, Node, and DOM utils.
Changes:
0.7.0
— important — If you've installed in the past eight days (since 0.6.17
), you're probably
seeing a lot of annoying logs! I did something dumb. Please update!0.6.0
— breaking — base64BufferDec
and base64BufferEnc
are now btoa
and atob
0.5.0
— breaking — hexRegex
is now a function, getHexRegex
0.4.0
— breaking — no longer require('zeelib').default
, just require('zeelib')
0.2.0
— breaking — all functions now in top level
- (No more
import { fp } from 'zeelib'
to use zipWith
, just import { zipWith } from 'zeelib'
)
Just a load of small utilities.
There's a full list at the bottom of this file.
Documentation is mostly just function names. Sorry.
Usage
import z from 'zeelib'
z.open('http://zacanger.com')
if (z.isEven(process.argv[2]))
z.camelCaseToLispCase('thisString')
You can also import individual functions.
import c from 'zeelib/dist/colorize'
console.log(c.bold(c.blue('HELLO THERE')))
If you're using require
with individual files you'll need to use default
:
const c = require('zeelib/dist/colorize').default
If you get errors when using zeelib
in a front-end build, you may need to use
something like Webpack's node
option. Try:
node: {
fs: 'empty',
net: 'empty',
tls: 'empty',
readline: 'empty',
child_process: 'empty'
}
Or, just import the functions you need (like
import words from 'zeelib/dist/words'
).
License
WTFPL
Contributing
- This project uses Flow.
- Please run
npm test
. - If you can, please add a test.
- Please add your thing in these places:
src/index.js
in the appropriate place- The full list below
- Make sure you run
npm run build
- (This also runs
test
, which also runs flow
and eslint
)
Full list:
dom
- getCookie
- getElementPosition
- getHeight
- getIsBrowser
- getLengthOfElements
- getReferrer
- getScrollBarWidth
- getWidth
- restoreScrollPosition
- scrollTop
regex, string utils, etc.
- abbrev
- abbrevNumber
- addCommasToNumber
- addNewlines
- alphaNumericOnly
- camelCaseToLispCase
- camelCaseToPascalCase
- camelCaseToSnakeCase
- capitalizeFirstChar
- collapseNewlines
- collapseWhitespace
- combineRegex
- cssToJson
- escapeForXpath
- escapeHtml
- fixWindowsSlashes
- formatMs
- getComplimentaryColors
- getHexRegex
- getQueryFromSearch
- getRandomHex32
- getRandomString
- getRegexFlags
- getUid4
- getUid8
- indenter
- inlineString
- isAlphaNumeric
- isEmoji
- isEmptyString
- isHexBased
- isMobileOrTablet
- isStringSomewhereInArray
- isValidEmail
- isValidHex
- isValidRegex
- lightenOrDarken
- lispCaseToCamelCase
- lispCaseToPascalCase
- lispCaseToSnakeCase
- minifyString
- moustache
- newlinesToSpaces
- normalizeClassname
- normalizeColor
- normalizeText
- pascalCaseToCamelCase
- pascalCaseToLispCase
- pascalCaseToSnakeCase
- randomColor
- removeNewlines
- removeNonAlpha
- removeNonAlphaNumeric
- removeNonAscii
- removeNonNumeric
- removeNumeric
- removeTags
- removeWhitespace
- rgbToHex
- rot13
- snakeCaseToCamelCase
- snakeCaseToLispCase
- snakeCaseToPascalCase
- stripHref
- stripPunctuation
- stripSubdomain
- toHttp
- toHttps
- trimHash
- trimSpaces
- truncate
- unescapeHtml
node
- atob
- btoa
- checkForFile
- colorize
- execute
- findPort
- getArgs
- getDiskUsage
- getFreeMemory
- getHashFromSystem
- getHostname
- getIsNode
- getLoadAverage
- getMemoryUsage
- getNodeModules
- getPlatform
- getTerminalColumns
- getTerminalRows
- getTerminalSize
- getUserHome
- getUserShell
- hasColor
- isDirectory
- isFile
- isInstalled
- isSymLink
- logWithInfo
- makeFileIfNoFile
- notFound
- open
- readFileSync
- readJson
- readJsonSync
- termPrompt
- timeRequire
- tinyRouter
- watch
- writeError
- writeJson
- writeJsonSync
fp utils
- all
- and
- any
- apply
- caar
- cadr
- car
- cdr
- clone
- compose
- concat
- concatMap
- cons
- constant
- curry
- curry2
- curry3
- curry4
- drop
- dropWhere
- dropWhile
- each
- elem
- eq
- filter
- findIndex
- findWhere
- flip
- foldl
- foldl1
- foldr
- foldr1
- getFunctionArguments
- head
- id
- init
- invoke
- last
- length
- lines
- map
- memoize
- mix
- not
- notElem
- once
- or
- pair
- pick
- pipe
- pluck
- propEq
- reduce
- replicate
- reverse
- span
- splitAt
- tail
- take
- takeLast
- takeWhile
- uncurry
- unfold
- unlines
- unwords
- unzip
- unzip3
- where
- words
- zip
- zip3
- zipThen
- zipWith
- zipWith3
types
- isArray
- isArrayLike
- isBoolean
- isBuffer
- isDate
- isDefined
- isDomElement
- isEmpty
- isError
- isEven
- isFloat
- isFunction
- isInteger
- isJson
- isNan
- isNegative
- isNodeList
- isNull
- isNullOrUndefined
- isNumber
- isObject
- isObjectEqual
- isOdd
- isPositive
- isPow2
- isPrimitive
- isPromise
- isRegExp
- isString
- isSymbol
- isType
- isUndefined
- objectToString
- toType
- typeOf
misc
- ago
- assert
- average
- chunk
- clamp
- cloneWithout
- contains
- copy
- copyWithout
- countItemsInArray
- debounce
- deepCopy
- diff
- dir
- doubleUntil
- filterFloat
- flatten
- flattenAndUniq
- generateSequence
- getBrokenImage
- getKeyByValue
- getKeyCodes
- getLengthOfCharactersInString
- getLengthOfItemsInArray
- getNiceDate
- getNow
- getOrdinal
- getTitle
- getTransparentGif
- greater
- greatestCommonDivisor
- inherits
- intersection
- invoker
- isObjectEmpty
- keys
- leastCommonMultiple
- leftPad
- lesser
- levenshteinDistance
- lexSort
- logWithTimestamp
- makeThunk
- maximum
- maybeArgs
- merge
- minimum
- nco
- noSwitch
- noop
- objectAssign
- objectClone
- objectFromEntries
- objectInherit
- product
- range
- reverseDigits
- scaleToFit
- setTitle
- shallowCopy
- shuffle
- sizeOf
- sleep
- splitStringOn
- sum
- tap
- throttle
- throwError
- timeTest
- toMap
- transpose
- transposeFlat
- tryExecNTimes
- uniq
- unless
- xor