This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const getQueryString = string => { | |
const newString = string.trim().replace(/^\?/, '') | |
const splittedAmpersandArr = newString.split('&') | |
let queryStringObj = {} | |
splittedAmpersandArr.forEach(value => { | |
const indexOfEqual = value.indexOf('=') | |
const key = value.slice(0, indexOfEqual) | |
const val = value.slice(indexOfEqual + 1, value.length) | |
const isArr = /[\[\]]{2}$/.test(key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const pluralize = word => { | |
const wordArr = word.split('') | |
const suffix = wordArr.pop() | |
switch (suffix) { | |
case 's': | |
case 'z': | |
case 'x': | |
return `${wordArr.join('')}${suffix}es` | |
case 'y': |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const hasDom = (typeof window !== 'undefined' && typeof document !== 'undefined') | |
export default hasDom |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default () => { | |
try { | |
const geoLocation = navigator.geolocation; | |
return new Promise((resolve, reject) => { | |
geoLocation.getCurrentPosition(resolve, reject, { | |
enableHighAccuracy: true, | |
}); | |
}); | |
} catch (error) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const scaleX = (baseWidth, width) => Math.round(baseWidth / width); | |
export const scaleY = (baseHeight, width) => Math.round(baseHeight / width); | |
export const cropXvalue = (x, scaleXvalue) => Math.round(x * scaleXvalue); | |
export const cropYvalue = (y, scaleYvalue) => Math.round(y * scaleYvalue); | |
export const cropWidthValue = (width, scaleXValue) => Math.round(width * scaleXValue); | |
export const cropHeightValue = (height, scaleYValue) => Math.round(height * scaleYValue); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import imageCompressor from 'browser-image-compression' | |
const blobToFile = async (blob, file) => { | |
const result = new File([blob], file.name, { type: file.type, lastModified: Date.now() }); | |
return result | |
} | |
const compressImage = async (maxWidth, file) => { | |
const options = { | |
maxWidthOrHeight: maxWidth, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: [push] | |
jobs: | |
test: | |
name: Test on node ${{ matrix.node }} and ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
branches: | |
- source | |
env: | |
NODE_ENV: production | |
PUBLIC_URL: http://crrmacarse.github.io/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { join, resolve } from 'path'; | |
import HtmlWebpackPlugin from 'html-webpack-plugin'; | |
import { CleanWebpackPlugin } from 'clean-webpack-plugin'; | |
export const entry = join(process.cwd(), '/src/index.tsx'); | |
export const output = { | |
path: join(process.cwd(), '/dist'), | |
filename: '[name].[hash].bundle.js', | |
chunkFilename: '[name].[hash].bundle.js', |
OlderNewer