Skip to content

Commit

Permalink
🔥 react-inspect: remove ramda
Browse files Browse the repository at this point in the history
  • Loading branch information
cloud-walker committed Aug 28, 2022
1 parent e079472 commit 2ab6d31
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 22 deletions.
5 changes: 5 additions & 0 deletions .changeset/wicked-garlics-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cloudwalker/react-inspect": patch
---

Remove ramda as dependency
3 changes: 1 addition & 2 deletions packages/react-inspect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@
"tsup": "^6.2.3"
},
"dependencies": {
"just-is-circular": "^2.1.1",
"ramda": "^0.28.0"
"just-is-circular": "^2.1.1"
},
"publishConfig": {
"access": "public"
Expand Down
22 changes: 11 additions & 11 deletions packages/react-inspect/src/components/DataHandler/DataHandler.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {addIndex, is, keys, map, pipe} from 'ramda'
import React from 'react'
import {keys, map, pipe} from 'remeda'

import stripFunction from '../../utils/stripFunction'
import CollapseHandler from '../CollapseHandler'
import Key from '../Key'
import Level from '../Level'
Expand All @@ -17,18 +16,18 @@ const Component = class extends React.Component {
render() {
const {data, outer, theme} = this.props

if (is(String)(data)) {
if (typeof data == 'string') {
return <Value type="string" theme={theme}>{`"${data}"`}</Value>
}

if (is(Number)(data)) {
if (typeof data == 'number') {
return <Value type="number" theme={theme}>{`${data}`}</Value>
}

if (is(Function)(data)) {
if (typeof data == 'function') {
const value = (
<Value type="function" theme={theme}>
{stripFunction(String(data))}
{String(data).trim()}
</Value>
)

Expand All @@ -45,12 +44,12 @@ const Component = class extends React.Component {
)
}

if (is(Array)(data)) {
const value = addIndex(map)((x, i) => (
if (Array.isArray(data)) {
const value = data.map((x, i) => (
<Level key={i}>
<Component data={x} theme={theme} />
</Level>
))(data)
))

return (
<span>
Expand All @@ -69,8 +68,9 @@ const Component = class extends React.Component {
)
}

if (is(Object)(data)) {
if (data != null && typeof data == 'object') {
const value = pipe(
data,
keys,
map((x) => (
<Level key={x}>
Expand All @@ -79,7 +79,7 @@ const Component = class extends React.Component {
<Component data={data[x]} theme={theme} />
</Level>
)),
)(data)
)

return (
<span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import isCircular from 'just-is-circular'
import {allPass, complement, is} from 'ramda'
import React from 'react'

import DataHandler from '../DataHandler'
import Layout from '../Layout'

const Component = ({data, theme}) => {
if (allPass([complement(is(Function)), is(Object), isCircular])(data)) {
if (
data != null &&
typeof data != 'function' &&
typeof data == 'object' &&
isCircular(data)
) {
throw new Error(
'ReactInspect Error: circular data inspection not supported',
)
Expand Down
7 changes: 0 additions & 7 deletions packages/react-inspect/src/utils/stripFunction.js

This file was deleted.

0 comments on commit 2ab6d31

Please sign in to comment.