Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@deck.gl/json

Package Overview
Dependencies
Maintainers
1
Versions
443
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@deck.gl/json - npm Package Compare versions

Comparing version 6.1.0-alpha.2 to 6.1.0-beta.1

dist-es6/json-converter/json-converter.js

6

dist-es6/index.js
//
// @deck.gl/json: top-level exports
//
export { default as JSONLayer } from './json-layer/json-layer';
export { default as JSONDeck } from './json-deck/json-deck';
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJuYW1lcyI6WyJkZWZhdWx0IiwiSlNPTkxheWVyIiwiSlNPTkRlY2siXSwibWFwcGluZ3MiOiJBQUFBO0FBQ0E7QUFDQTtBQUVBLFNBQVFBLE9BQU8sSUFBSUMsU0FBbkIsUUFBbUMseUJBQW5DO0FBQ0EsU0FBUUQsT0FBTyxJQUFJRSxRQUFuQixRQUFrQyx1QkFBbEMiLCJzb3VyY2VzQ29udGVudCI6WyIvL1xuLy8gQGRlY2suZ2wvanNvbjogdG9wLWxldmVsIGV4cG9ydHNcbi8vXG5cbmV4cG9ydCB7ZGVmYXVsdCBhcyBKU09OTGF5ZXJ9IGZyb20gJy4vanNvbi1sYXllci9qc29uLWxheWVyJztcbmV4cG9ydCB7ZGVmYXVsdCBhcyBKU09ORGVja30gZnJvbSAnLi9qc29uLWRlY2svanNvbi1kZWNrJztcbiJdfQ==
export { default as _JSONConverter } from './json-converter/json-converter';
export { default as _JSONLayer } from './json-layer/json-layer';
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJuYW1lcyI6WyJkZWZhdWx0IiwiX0pTT05Db252ZXJ0ZXIiLCJfSlNPTkxheWVyIl0sIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFFQSxTQUFRQSxPQUFPLElBQUlDLGNBQW5CLFFBQXdDLGlDQUF4QztBQUNBLFNBQVFELE9BQU8sSUFBSUUsVUFBbkIsUUFBb0MseUJBQXBDIiwic291cmNlc0NvbnRlbnQiOlsiLy9cbi8vIEBkZWNrLmdsL2pzb246IHRvcC1sZXZlbCBleHBvcnRzXG4vL1xuXG5leHBvcnQge2RlZmF1bHQgYXMgX0pTT05Db252ZXJ0ZXJ9IGZyb20gJy4vanNvbi1jb252ZXJ0ZXIvanNvbi1jb252ZXJ0ZXInO1xuZXhwb3J0IHtkZWZhdWx0IGFzIF9KU09OTGF5ZXJ9IGZyb20gJy4vanNvbi1sYXllci9qc29uLWxheWVyJztcbiJdfQ==
import { CompositeLayer } from '@deck.gl/core';
import { get } from '../utils/get';
import { getJSONLayers } from '../parsers/convert-json';
const defaultProps = {
layerCatalog: []
configuration: []
};

@@ -17,3 +17,3 @@ export default class JSONLayer extends CompositeLayer {

}) {
const layersChanged = props.data !== oldProps.data || props.layerCatalog !== oldProps.layerCatalog;
const layersChanged = props.data !== oldProps.data || props.configuration !== oldProps.configuration;

@@ -23,52 +23,6 @@ if (layersChanged) {

const data = typeof props.data === 'string' ? JSON.parse(props.data) : props.data;
this.state.layers = this._getJSONLayers(data, props.layerCatalog);
this.state.layers = getJSONLayers(data, props.configuration);
}
}
_getJSONLayers(jsonLayers = [], layerCatalog) {
// assert(Array.isArray(jsonLayers));
return jsonLayers.map(jsonLayer => {
const Layer = layerCatalog[jsonLayer.type];
const props = this._getJSONLayerProps(jsonLayer);
return Layer && new Layer(props);
});
} // Replaces accessor props
_getJSONLayerProps(jsonProps) {
const replacedProps = {};
for (const propName in jsonProps) {
// eslint-disable-line guard-for-in
const propValue = jsonProps[propName]; // Handle accessors
if (propName.startsWith('get')) {
replacedProps[propName] = this._getJSONAccessor(propValue);
} else {
replacedProps[propName] = propValue;
}
}
return replacedProps;
} // Calculates an accessor function from a JSON string
// '-' : x => x
// 'a.b.c': x => x.a.b.c
_getJSONAccessor(propValue) {
if (propValue === '-') {
return object => object;
}
if (typeof propValue === 'string') {
return object => {
return get(object, propValue);
};
}
return propValue;
}
renderLayers() {

@@ -79,4 +33,4 @@ return this.state.layers;

}
JSONLayer.layerName = 'jsonLayer';
JSONLayer.layerName = 'JSONLayer';
JSONLayer.defaultProps = defaultProps;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9qc29uLWxheWVyL2pzb24tbGF5ZXIuanMiXSwibmFtZXMiOlsiQ29tcG9zaXRlTGF5ZXIiLCJnZXQiLCJkZWZhdWx0UHJvcHMiLCJsYXllckNhdGFsb2ciLCJKU09OTGF5ZXIiLCJpbml0aWFsaXplU3RhdGUiLCJzdGF0ZSIsImxheWVycyIsInVwZGF0ZVN0YXRlIiwicHJvcHMiLCJvbGRQcm9wcyIsImxheWVyc0NoYW5nZWQiLCJkYXRhIiwiSlNPTiIsInBhcnNlIiwiX2dldEpTT05MYXllcnMiLCJqc29uTGF5ZXJzIiwibWFwIiwianNvbkxheWVyIiwiTGF5ZXIiLCJ0eXBlIiwiX2dldEpTT05MYXllclByb3BzIiwianNvblByb3BzIiwicmVwbGFjZWRQcm9wcyIsInByb3BOYW1lIiwicHJvcFZhbHVlIiwic3RhcnRzV2l0aCIsIl9nZXRKU09OQWNjZXNzb3IiLCJvYmplY3QiLCJyZW5kZXJMYXllcnMiLCJsYXllck5hbWUiXSwibWFwcGluZ3MiOiJBQUFBLFNBQVFBLGNBQVIsUUFBNkIsZUFBN0I7QUFDQSxTQUFRQyxHQUFSLFFBQWtCLGNBQWxCO0FBRUEsTUFBTUMsWUFBWSxHQUFHO0FBQ25CQyxFQUFBQSxZQUFZLEVBQUU7QUFESyxDQUFyQjtBQUlBLGVBQWUsTUFBTUMsU0FBTixTQUF3QkosY0FBeEIsQ0FBdUM7QUFDcERLLEVBQUFBL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ydC1qc29uJztcblxuY29uc3QgZGVmYXVsdFByb3BzID0ge1xuICBjb25maWd1cmF0aW9uOiBbXVxufTtcblxuZXhwb3J0IGRlZmF1bHQgY2xhc3MgSlNPTkxheWVyIGV4dGVuZHMgQ29tcG9zaXRlTGF5ZXIge1xuICBpbml0aWFsaXplU3RhdGUoKSB7XG4gICAgdGhpcy5zdGF0ZSA9IHtcbiAgICAgIGxheWVyczogW11cbiAgICB9O1xuICB9XG5cbiAgdXBkYXRlU3RhdGUoe3Byb3BzLCBvbGRQcm9wc30pIHtcbiAgICBjb25zdCBsYXllcnNDaGFuZ2VkID1cbiAgICAgIHByb3BzLmRhdGEgIT09IG9sZFByb3BzLmRhdGEgfHwgcHJvcHMuY29uZmlndXJhdGlvbiAhPT0gb2xkUHJvcHMuY29uZmlndXJhdGlvbjtcblxuICAgIGlmIChsYXllcnNDaGFuZ2VkKSB7XG4gICAgICAvLyBPcHRpb25hbGx5IGFjY2VwdCBKU09OIHN0cmluZ3MgYnkgcGFyc2luZyB0aGVtXG4gICAgICBjb25zdCBkYXRhID0gdHlwZW9mIHByb3BzLmRhdGEgPT09ICdzdHJpbmcnID8gSlNPTi5wYXJzZShwcm9wcy5kYXRhKSA6IHByb3BzLmRhdGE7XG4gICAgICB0aGlzLnN0YXRlLmxheWVycyA9IGdldEpTT05MYXllcnMoZGF0YSwgcHJvcHMuY29uZmlndXJhdGlvbik7XG4gICAgfVxuICB9XG5cbiAgcmVuZGVyTGF5ZXJzKCkge1xuICAgIHJldHVybiB0aGlzLnN0YXRlLmxheWVycztcbiAgfVxufVxuXG5KU09OTGF5ZXIubGF5ZXJOYW1lID0gJ0pTT05MYXllcic7XG5KU09OTGF5ZXIuZGVmYXVsdFByb3BzID0gZGVmYXVsdFByb3BzO1xuIl19
//
// @deck.gl/json: top-level exports
//
export { default as JSONLayer } from './json-layer/json-layer';
export { default as JSONDeck } from './json-deck/json-deck';
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJuYW1lcyI6WyJkZWZhdWx0IiwiSlNPTkxheWVyIiwiSlNPTkRlY2siXSwibWFwcGluZ3MiOiJBQUFBO0FBQ0E7QUFDQTtBQUVBLFNBQVFBLE9BQU8sSUFBSUMsU0FBbkIsUUFBbUMseUJBQW5DO0FBQ0EsU0FBUUQsT0FBTyxJQUFJRSxRQUFuQixRQUFrQyx1QkFBbEMiLCJzb3VyY2VzQ29udGVudCI6WyIvL1xuLy8gQGRlY2suZ2wvanNvbjogdG9wLWxldmVsIGV4cG9ydHNcbi8vXG5cbmV4cG9ydCB7ZGVmYXVsdCBhcyBKU09OTGF5ZXJ9IGZyb20gJy4vanNvbi1sYXllci9qc29uLWxheWVyJztcbmV4cG9ydCB7ZGVmYXVsdCBhcyBKU09ORGVja30gZnJvbSAnLi9qc29uLWRlY2svanNvbi1kZWNrJztcbiJdfQ==
export { default as _JSONConverter } from './json-converter/json-converter';
export { default as _JSONLayer } from './json-layer/json-layer';
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJuYW1lcyI6WyJkZWZhdWx0IiwiX0pTT05Db252ZXJ0ZXIiLCJfSlNPTkxheWVyIl0sIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFFQSxTQUFRQSxPQUFPLElBQUlDLGNBQW5CLFFBQXdDLGlDQUF4QztBQUNBLFNBQVFELE9BQU8sSUFBSUUsVUFBbkIsUUFBb0MseUJBQXBDIiwic291cmNlc0NvbnRlbnQiOlsiLy9cbi8vIEBkZWNrLmdsL2pzb246IHRvcC1sZXZlbCBleHBvcnRzXG4vL1xuXG5leHBvcnQge2RlZmF1bHQgYXMgX0pTT05Db252ZXJ0ZXJ9IGZyb20gJy4vanNvbi1jb252ZXJ0ZXIvanNvbi1jb252ZXJ0ZXInO1xuZXhwb3J0IHtkZWZhdWx0IGFzIF9KU09OTGF5ZXJ9IGZyb20gJy4vanNvbi1sYXllci9qc29uLWxheWVyJztcbiJdfQ==
import { CompositeLayer } from '@deck.gl/core';
import { get } from '../utils/get';
import { getJSONLayers } from '../parsers/convert-json';
const defaultProps = {
layerCatalog: []
configuration: []
};

@@ -17,3 +17,3 @@ export default class JSONLayer extends CompositeLayer {

}) {
const layersChanged = props.data !== oldProps.data || props.layerCatalog !== oldProps.layerCatalog;
const layersChanged = props.data !== oldProps.data || props.configuration !== oldProps.configuration;

@@ -23,52 +23,6 @@ if (layersChanged) {

const data = typeof props.data === 'string' ? JSON.parse(props.data) : props.data;
this.state.layers = this._getJSONLayers(data, props.layerCatalog);
this.state.layers = getJSONLayers(data, props.configuration);
}
}
_getJSONLayers(jsonLayers = [], layerCatalog) {
// assert(Array.isArray(jsonLayers));
return jsonLayers.map(jsonLayer => {
const Layer = layerCatalog[jsonLayer.type];
const props = this._getJSONLayerProps(jsonLayer);
return Layer && new Layer(props);
});
} // Replaces accessor props
_getJSONLayerProps(jsonProps) {
const replacedProps = {};
for (const propName in jsonProps) {
// eslint-disable-line guard-for-in
const propValue = jsonProps[propName]; // Handle accessors
if (propName.startsWith('get')) {
replacedProps[propName] = this._getJSONAccessor(propValue);
} else {
replacedProps[propName] = propValue;
}
}
return replacedProps;
} // Calculates an accessor function from a JSON string
// '-' : x => x
// 'a.b.c': x => x.a.b.c
_getJSONAccessor(propValue) {
if (propValue === '-') {
return object => object;
}
if (typeof propValue === 'string') {
return object => {
return get(object, propValue);
};
}
return propValue;
}
renderLayers() {

@@ -79,4 +33,4 @@ return this.state.layers;

}
JSONLayer.layerName = 'jsonLayer';
JSONLayer.layerName = 'JSONLayer';
JSONLayer.defaultProps = defaultProps;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9qc29uLWxheWVyL2pzb24tbGF5ZXIuanMiXSwibmFtZXMiO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IHByb3BzLmRhdGEgIT09IG9sZFByb3BzLmRhdGEgfHwgcHJvcHMuY29uZmlndXJhdGlvbiAhPT0gb2xkUHJvcHMuY29uZmlndXJhdGlvbjtcblxuICAgIGlmIChsYXllcnNDaGFuZ2VkKSB7XG4gICAgICAvLyBPcHRpb25hbGx5IGFjY2VwdCBKU09OIHN0cmluZ3MgYnkgcGFyc2luZyB0aGVtXG4gICAgICBjb25zdCBkYXRhID0gdHlwZW9mIHByb3BzLmRhdGEgPT09ICdzdHJpbmcnID8gSlNPTi5wYXJzZShwcm9wcy5kYXRhKSA6IHByb3BzLmRhdGE7XG4gICAgICB0aGlzLnN0YXRlLmxheWVycyA9IGdldEpTT05MYXllcnMoZGF0YSwgcHJvcHMuY29uZmlndXJhdGlvbik7XG4gICAgfVxuICB9XG5cbiAgcmVuZGVyTGF5ZXJzKCkge1xuICAgIHJldHVybiB0aGlzLnN0YXRlLmxheWVycztcbiAgfVxufVxuXG5KU09OTGF5ZXIubGF5ZXJOYW1lID0gJ0pTT05MYXllcic7XG5KU09OTGF5ZXIuZGVmYXVsdFByb3BzID0gZGVmYXVsdFByb3BzO1xuIl19

@@ -5,3 +5,3 @@ {

"license": "MIT",
"version": "6.1.0-alpha.2",
"version": "6.1.0-beta.1",
"publishConfig": {

@@ -36,4 +36,5 @@ "access": "public"

"dependencies": {
"@deck.gl/core": "^6.1.0-alpha.2"
"@deck.gl/core": "^6.1.0-beta.1",
"d3-dsv": "^1.0.8"
}
}

@@ -7,1 +7,8 @@ # @deck.gl/json

<div align="center">
<div>
<img src="https://raw.github.com/uber-common/deck.gl-data/master/images/docs/json-layers.gif" />
<p><i>PoC: JSON layer browser built on new @deck.gl/json module.</i></p>
</div>
</div>

@@ -5,3 +5,3 @@ //

export {default as JSONLayer} from './json-layer/json-layer';
export {default as JSONDeck} from './json-deck/json-deck';
export {default as _JSONConverter} from './json-converter/json-converter';
export {default as _JSONLayer} from './json-layer/json-layer';
import {CompositeLayer} from '@deck.gl/core';
import {get} from '../utils/get';
import {getJSONLayers} from '../parsers/convert-json';
const defaultProps = {
layerCatalog: []
configuration: []
};

@@ -17,3 +17,3 @@

const layersChanged =
props.data !== oldProps.data || props.layerCatalog !== oldProps.layerCatalog;
props.data !== oldProps.data || props.configuration !== oldProps.configuration;

@@ -23,46 +23,6 @@ if (layersChanged) {

const data = typeof props.data === 'string' ? JSON.parse(props.data) : props.data;
this.state.layers = this._getJSONLayers(data, props.layerCatalog);
this.state.layers = getJSONLayers(data, props.configuration);
}
}
_getJSONLayers(jsonLayers = [], layerCatalog) {
// assert(Array.isArray(jsonLayers));
return jsonLayers.map(jsonLayer => {
const Layer = layerCatalog[jsonLayer.type];
const props = this._getJSONLayerProps(jsonLayer);
return Layer && new Layer(props);
});
}
// Replaces accessor props
_getJSONLayerProps(jsonProps) {
const replacedProps = {};
for (const propName in jsonProps) {
// eslint-disable-line guard-for-in
const propValue = jsonProps[propName];
// Handle accessors
if (propName.startsWith('get')) {
replacedProps[propName] = this._getJSONAccessor(propValue);
} else {
replacedProps[propName] = propValue;
}
}
return replacedProps;
}
// Calculates an accessor function from a JSON string
// '-' : x => x
// 'a.b.c': x => x.a.b.c
_getJSONAccessor(propValue) {
if (propValue === '-') {
return object => object;
}
if (typeof propValue === 'string') {
return object => {
return get(object, propValue);
};
}
return propValue;
}
renderLayers() {

@@ -73,3 +33,3 @@ return this.state.layers;

JSONLayer.layerName = 'jsonLayer';
JSONLayer.layerName = 'JSONLayer';
JSONLayer.defaultProps = defaultProps;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc