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

@coorpacademy/treantjs-adapter-dust

Package Overview
Dependencies
Maintainers
15
Versions
269
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@coorpacademy/treantjs-adapter-dust - npm Package Compare versions

Comparing version 3.7.3 to 4.0.0

.nyc_output/069015172d1d99a95d431b30963f87cb.json

19

es/index.js
import map from 'lodash/fp/map';
import toPairs from 'lodash/fp/toPairs';
import kebabCase from 'lodash/fp/kebabCase';
import * as treant from '@coorpacademy/treantjs-core';
import { renderToString } from '@coorpacademy/treantjs-engine-virtual-dom';
var toHelpers = function toHelpers(factories, skin) {
var toHelpers = function toHelpers(React, ReactDOMServer, components) {
var toHelper = function toHelper(_ref) {
var key = _ref[0],
factory = _ref[1];
var componentName = _ref[0],
Component = _ref[1];
var isFactory = key.split('create')[1];
if (!isFactory) return;
var componentName = kebabCase(isFactory);
var Component = factory(treant, { skin: skin });
return function (dust, options) {
dust.helpers[componentName] = function (chunk, context, bodies, props) {
var vTree = Component(props);
var html = renderToString(vTree);
var vTree = React.createElement(Component, props);
var html = ReactDOMServer.renderToString(vTree);
chunk.write(html);

@@ -26,3 +19,3 @@ };

return map(toHelper, toPairs(factories));
return map(toHelper, toPairs(components));
};

@@ -29,0 +22,0 @@

@@ -17,26 +17,13 @@ 'use strict';

var _treantjsCore = require('@coorpacademy/treantjs-core');
var treant = _interopRequireWildcard(_treantjsCore);
var _treantjsEngineVirtualDom = require('@coorpacademy/treantjs-engine-virtual-dom');
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var toHelpers = function toHelpers(factories, skin) {
var toHelpers = function toHelpers(React, ReactDOMServer, components) {
var toHelper = function toHelper(_ref) {
var key = _ref[0],
factory = _ref[1];
var componentName = _ref[0],
Component = _ref[1];
var isFactory = key.split('create')[1];
if (!isFactory) return;
var componentName = (0, _kebabCase2.default)(isFactory);
var Component = factory(treant, { skin: skin });
return function (dust, options) {
dust.helpers[componentName] = function (chunk, context, bodies, props) {
var vTree = Component(props);
var html = (0, _treantjsEngineVirtualDom.renderToString)(vTree);
var vTree = React.createElement(Component, props);
var html = ReactDOMServer.renderToString(vTree);
chunk.write(html);

@@ -47,3 +34,3 @@ };

return (0, _map2.default)(toHelper, (0, _toPairs2.default)(factories));
return (0, _map2.default)(toHelper, (0, _toPairs2.default)(components));
};

@@ -50,0 +37,0 @@

{
"name": "@coorpacademy/treantjs-adapter-dust",
"version": "3.7.3",
"version": "4.0.0",
"description": "",

@@ -23,4 +23,2 @@ "main": "lib/index.js",

"dependencies": {
"@coorpacademy/treantjs-core": "^3.7.3",
"@coorpacademy/treantjs-engine-virtual-dom": "^3.7.3",
"lodash": "^4.14.1"

@@ -33,5 +31,7 @@ },

"babel-preset-es2015": "^6.13.0",
"babel-preset-stage-1": "^6.5.0"
"babel-preset-stage-1": "^6.5.0",
"react": "^15.4.1",
"react-dom": "^15.4.1"
},
"author": "CoorpAcademy"
}
import map from 'lodash/fp/map';
import toPairs from 'lodash/fp/toPairs';
import kebabCase from 'lodash/fp/kebabCase';
import * as treant from '@coorpacademy/treantjs-core';
import {renderToString} from '@coorpacademy/treantjs-engine-virtual-dom';
const toHelpers = (factories, skin) => {
const toHelper = ([key, factory]) => {
const isFactory = key.split('create')[1];
if (!isFactory) return;
const componentName = kebabCase(isFactory);
const Component = factory(treant, {skin});
const toHelpers = (React, ReactDOMServer, components) => {
const toHelper = ([componentName, Component]) => {
return (dust, options) => {
dust.helpers[componentName] = (chunk, context, bodies, props) => {
const vTree = Component(props);
const html = renderToString(vTree);
const vTree = React.createElement(Component, props);
const html = ReactDOMServer.renderToString(vTree);
chunk.write(html);

@@ -23,5 +16,5 @@ };

return map(toHelper, toPairs(factories));
return map(toHelper, toPairs(components));
};
export default toHelpers;
import test from 'ava';
import isArray from 'lodash/fp/isArray';
import isFunction from 'lodash/fp/isFunction';
import React from 'react';
import ReactDOMServer from 'react-dom/server';
import toHelpers from '..';
test('toHelpers should transform factories as helpers', t => {
const factories = {
createStarRating: (_treant, options) => (props, children) => true,
createCatalogCard: (_treant, options) => (props, children) => true
const components = {
StarRating: () => true,
CatalogCard: () => true
};
const helpers = toHelpers(factories);
const helpers = toHelpers(React, ReactDOMServer, components);

@@ -14,0 +16,0 @@ t.true(isArray(helpers));

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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