Skip to content

Commit

Permalink
BREAKING CHANGE: remove checks for a valid value
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewvasilchuk committed Sep 20, 2020
1 parent 4003b73 commit 17627ec
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 28 deletions.
3 changes: 0 additions & 3 deletions src/config.js

This file was deleted.

27 changes: 2 additions & 25 deletions src/helpers.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,4 @@
import config from './config'

export function applyDirective(value, style) {
if (!value) {
throw new Error('No value provided')
}

if (typeof value !== 'string') {
throw new Error(
`Expected directive binding value type to be a string but found a ${typeof value} instead`
)
}

if (!config.pattern.test(value)) {
throw new Error(
`Expected directive value to match pattern "[Integer]:[Integer]" gut got a ${value}`
)
}

const values = value.split(':').map(Number)

if (values[0] === 0) {
throw new Error('Division by 0')
}

style.paddingBottom = `${(values[1] / values[0]) * 100}%`
const [x, y] = value.split(':').map(Number)
style.paddingBottom = `${(y / x) * 100}%`
}

0 comments on commit 17627ec

Please sign in to comment.