Sharyn is a collection of JavaScript / TypeScript packages that make your life easier and reduce your boilerplate code.
Note: I have ported the most useful of those packages over to my new repository V1V2.
-
@sharyn/util β Lodash-like utils:
- between β Tests if a value is between two bounds
- cycle β Cycles between multiple values
- either β Tests equality with multiple values
- exists β Returns
true
if notnull
orundefined
- global β Functions to create and access global variables
- ifs β An
if
,else if
,else if
...else
util - inlineThrow β To
throw
in an expression - invoke β A self invoking function util
- swit β An inline and less verbose
switch
- toggle β Toggles between two values
- tryCatch β An inline
try
-catch
-finally
- wait β A
Promise
-based delay
-
@sharyn/scripts β Helpers to write "NPM scripts" in a JavaScript file
-
@sharyn/tags β No-op ES6 template string tags to enable syntax highlighting in editors:
-
@sharyn/nanoid β A Nano ID default configuration
-
@sharyn/actions β Flux Standard Actions creator functions
-
@sharyn/chakra-next β Next Link applied to Chakra UI components
-
@sharyn/react-hooks β React Hooks:
- useStateObject β A hook to manage a state that is an object
-
@sharyn/react-router β Components for React Router:
- PrivateRoute β A
Route
that redirects unauthenticated users - ServerOnlyRoute β A
Route
that refreshes the page on the client
- PrivateRoute β A
-
@sharyn/browser β Helpers for code that runs in the browser:
- clearCaches β Clears all the service worker caches
- getFormData β Gives you the form data as a plain object
- @sharyn/prettier β A Prettier configuration
- @sharyn/tsconfig β TypeScript configurations
- babel-preset-sharyn β A Babel preset for React and Flow (not included in sharyn-dev)
- eslint-config-sharyn β An ESLint configuration for Babel, React and Flow (not included in sharyn-dev)
Depending on your needs, you can install individual modules, like @sharyn/util.swit, a group of modules, like @sharyn/util, or the whole library. If you want to install everything, run:
npm i sharyn && npm i --save-dev sharyn-dev
# or
yarn add sharyn && yarn add --dev sharyn-dev
This will install sharyn in your dependencies
and sharyn-dev in your devDependencies
.
If you use sharyn/react-hooks
or sharyn/react-router
which are included, you will need to install react
and react-router
too. They are not listed as peerDependencies
to avoid noise in projects that want to use sharyn
without React.
And depending on what packages you chose to install, you have different ways to import
or require
a module:
// If you installed an individual package (all lowercase)
import swit from '@sharyn/util.swit'
// If you installed a group of modules like '@sharyn/util'
import swit from '@sharyn/util/swit'
import { swit } from '@sharyn/util'
// If you installed the whole 'sharyn' library
import swit from 'sharyn/util/swit'
import { swit } from 'sharyn/util'
Note: TypeScript users, you need your esModuleInterop
set to true
if you want to import the default exports without having to use the *
syntax.
By Jonathan Verrecchia (verekia) Github β’ Twitter β’ Website β MIT License
Sharyn is a reference to one of my favorite metalcore songs, Rose of Sharyn by Killswitch Engage.
Rose illustration by tiaesther_4360