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

@slate-serializers/utilities

Package Overview
Dependencies
Maintainers
0
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@slate-serializers/utilities - npm Package Compare versions

Comparing version 2.1.6 to 2.2.0

8

package.json
{
"name": "@slate-serializers/utilities",
"version": "2.1.6",
"version": "2.2.0",
"type": "commonjs",
"dependencies": {
"postcss": "^8.4.24",
"postcss": "8.4.38",
"postcss-js": "^4.0.1",
"tslib": "2.5.0"
"tslib": "2.6.3"
},
"main": "./src/index.js"
}
}
export * from './lib/style-object';
export * from './lib/utilities';
export * from './lib/blocks';

@@ -6,3 +6,2 @@ "use strict";

tslib_1.__exportStar(require("./lib/utilities"), exports);
tslib_1.__exportStar(require("./lib/blocks"), exports);
//# sourceMappingURL=index.js.map
export declare const hasLineBreak: (str: string) => boolean;
export declare const prependSpace: (str: string) => string;
export declare const parseStyleCssText: (value: string) => {
[key: string]: string;
};
export declare const styleToString: (style: {
[key: string]: string;
}) => string;
export declare const isEmptyObject: (obj: any) => any;

@@ -18,16 +12,1 @@ export declare const removeEmpty: (obj: {}) => {};

export declare const getNested: (obj: any, ...args: string[]) => any;
export declare const encodeBreakingEntities: (str: string) => string;
export declare const decodeBreakingEntities: (str: string) => string;
export declare const intersection: (o1: {
[key: string]: any;
}, o2: {
[key: string]: any;
}) => string[];
export declare const styleMapToAttribs: ({ elementStyleMap, node, }: {
elementStyleMap: {
[key: string]: string;
};
node: any;
}) => {
[key: string]: any;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.styleMapToAttribs = exports.intersection = exports.decodeBreakingEntities = exports.encodeBreakingEntities = exports.getNested = exports.removeEmpty = exports.isEmptyObject = exports.styleToString = exports.parseStyleCssText = exports.prependSpace = exports.hasLineBreak = void 0;
exports.getNested = exports.removeEmpty = exports.isEmptyObject = exports.prependSpace = exports.hasLineBreak = void 0;
const hasLineBreak = (str) => str.match(/[\r\n]+/) !== null;

@@ -8,36 +8,2 @@ exports.hasLineBreak = hasLineBreak;

exports.prependSpace = prependSpace;
const camelize = (str) => {
return str.replace(/(?:^|[-])(\w)/g, (a, c) => {
c = a.substring(0, 1) === '-' ? c.toUpperCase() : c;
return c ? c : '';
});
};
const parseStyleCssText = (value) => {
const output = {};
if (!value) {
return output;
}
const style = value.split(';');
for (const s of style) {
const rule = s.trim();
if (rule) {
const ruleParts = rule.split(':');
const key = camelize(ruleParts[0].trim());
output[key] = ruleParts[1].trim();
}
}
return output;
};
exports.parseStyleCssText = parseStyleCssText;
const styleToString = (style) => {
return Object.keys(style).reduce((acc, key) => acc +
key
.split(/(?=[A-Z])/)
.join('-')
.toLowerCase() +
':' +
style[key] +
';', '');
};
exports.styleToString = styleToString;
const isEmptyObject = (obj) => obj && Object.keys(obj).length === 0 && Object.getPrototypeOf(obj) === Object.prototype;

@@ -59,54 +25,2 @@ exports.isEmptyObject = isEmptyObject;

exports.getNested = getNested;
const encodeBreakingEntities = (str) => {
const swapChar = (charToSwap) => {
// that swaps characters to HTML entities
switch (charToSwap) {
case '&':
return '&';
case '<':
return '&lt;';
case '>':
return '&gt;';
default:
return charToSwap;
}
};
str = str.replace(/[&<>]/g, (match) => {
return swapChar(match);
});
return str;
};
exports.encodeBreakingEntities = encodeBreakingEntities;
const decodeBreakingEntities = (str) => {
return str.replace(/&amp;/g, '&').replace(/&lt;/g, '<').replace(/&gt;/g, '>');
};
exports.decodeBreakingEntities = decodeBreakingEntities;
const intersection = (o1, o2) => {
return Object.keys(o1)
.concat(Object.keys(o2))
.sort()
.reduce((r, a, i, aa) => {
if (i && aa[i - 1] === a) {
r.push(a);
}
return r;
}, []);
};
exports.intersection = intersection;
const styleMapToAttribs = ({ elementStyleMap, node, }) => {
let attribs = {};
const styleAttrs = {};
Object.keys(elementStyleMap).forEach((slateKey) => {
const cssProperty = elementStyleMap[slateKey];
const cssValue = node[slateKey];
if (cssValue) {
styleAttrs[cssProperty] = cssValue;
}
});
if (!(0, exports.isEmptyObject)(styleAttrs)) {
attribs = Object.assign(Object.assign({}, attribs), { style: (0, exports.styleToString)(styleAttrs) });
}
return (0, exports.isEmptyObject)(attribs) ? {} : attribs;
};
exports.styleMapToAttribs = styleMapToAttribs;
//# sourceMappingURL=utilities.js.map

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