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

abstract-sheet

Package Overview
Dependencies
Maintainers
0
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abstract-sheet - npm Package Compare versions

Comparing version 0.0.14 to 0.0.15

2

lib/abstract-sheet-exporters/csv.d.ts

@@ -16,3 +16,3 @@ import { AbstractSheet } from "../abstract-sheet/abstract-sheet.js";

};
export declare function toCsv(abstractSheets: ReadonlyArray<AbstractSheet>, options?: CsvOptions): ReadonlyArray<ReadonlyArray<CsvFile>>;
export declare function toCsv(as: AbstractSheet, options?: CsvOptions): ReadonlyArray<CsvFile>;
//# sourceMappingURL=csv.d.ts.map

@@ -40,20 +40,18 @@ "use strict";

const _style_js_1 = require("./_style.js");
function toCsv(abstractSheets, options) {
return abstractSheets.map((as) => {
const styles = Object.fromEntries(as.styles?.map((s) => [s.name, (0, _style_js_1.createStyle)(s)]) ?? []);
const mappedOptions = options
? {
FS: options.separator,
RS: options.rowSeparator,
strip: options.noTrailingSeparator,
blankrows: options.blankRows,
skipHidden: options.skipHidden,
forceQuotes: options.forceQuotes,
rawNumbers: options.rawNumber,
dateNF: options.dateFormat,
}
: undefined;
return as.sheets.map((s) => ({ name: s.name, csv: XLSX.utils.sheet_to_csv((0, _xlsx_sheet_js_1.xlsxWorkSheet)(s, styles), mappedOptions) }));
});
function toCsv(as, options) {
const styles = Object.fromEntries(as.styles?.map((s) => [s.name, (0, _style_js_1.createStyle)(s)]) ?? []);
const mappedOptions = options
? {
FS: options.separator,
RS: options.rowSeparator,
strip: options.noTrailingSeparator,
blankrows: options.blankRows,
skipHidden: options.skipHidden,
forceQuotes: options.forceQuotes,
rawNumbers: options.rawNumber,
dateNF: options.dateFormat,
}
: undefined;
return as.sheets.map((s) => ({ name: s.name, csv: XLSX.utils.sheet_to_csv((0, _xlsx_sheet_js_1.xlsxWorkSheet)(s, styles), mappedOptions) }));
}
//# sourceMappingURL=csv.js.map
import { AbstractSheet } from "../abstract-sheet/abstract-sheet.js";
export declare function toXlsx(...abstractSheets: ReadonlyArray<AbstractSheet>): Buffer;
export declare function toXlsx(as: AbstractSheet): Buffer;
//# sourceMappingURL=xlsx.d.ts.map

@@ -40,11 +40,9 @@ "use strict";

const _style_js_1 = require("./_style.js");
function toXlsx(...abstractSheets) {
function toXlsx(as) {
const sheets = {};
const sheetNames = Array();
for (const as of abstractSheets) {
const styles = Object.fromEntries(as.styles?.map((s) => [s.name, (0, _style_js_1.createStyle)(s)]) ?? []);
for (const s of as.sheets) {
sheetNames.push(s.name);
sheets[s.name] = (0, _xlsx_sheet_js_1.xlsxWorkSheet)(s, styles);
}
const styles = Object.fromEntries(as.styles?.map((s) => [s.name, (0, _style_js_1.createStyle)(s)]) ?? []);
for (const s of as.sheets) {
sheetNames.push(s.name);
sheets[s.name] = (0, _xlsx_sheet_js_1.xlsxWorkSheet)(s, styles);
}

@@ -51,0 +49,0 @@ const wb = { Sheets: sheets, SheetNames: Object.keys(sheets) };

import { AbstractSheet } from "../abstract-sheet/abstract-sheet.js";
import { XmlElement } from "./mustache-xml/index.js";
export declare const abstractSheetXml: (template: string, data: any, partials: Record<string, string>, sheetPrefix?: string) => AbstractSheet;
export declare function abstractSheetOfXml(el: XmlElement, sheetPrefix?: string): unknown;
export declare const abstractSheetXml: (template: string, data: any, partials: Record<string, string>) => AbstractSheet;
export declare function abstractSheetOfXml(el: XmlElement): unknown;
export declare const parsedXsd: readonly XmlElement[];
//# sourceMappingURL=abstract-sheet-xml.d.ts.map

@@ -8,5 +8,5 @@ "use strict";

const index_js_1 = require("./mustache-xml/index.js");
const abstractSheetXml = (template, data, partials, sheetPrefix) => abstractSheetOfXml((0, index_js_1.parseMustacheXml)(template, data, partials)[0], sheetPrefix);
const abstractSheetXml = (template, data, partials) => abstractSheetOfXml((0, index_js_1.parseMustacheXml)(template, data, partials)[0]);
exports.abstractSheetXml = abstractSheetXml;
function abstractSheetOfXml(el, sheetPrefix) {
function abstractSheetOfXml(el) {
const children = Array();

@@ -16,3 +16,3 @@ const childElements = Array();

if (child.tagName !== undefined) {
children.push(abstractSheetOfXml(child, sheetPrefix));
children.push(abstractSheetOfXml(child));
childElements.push(child);

@@ -50,3 +50,3 @@ }

return {
name: `${sheetPrefix ?? ""}${(el.attributes?.name ?? "")}`,
name: (el.attributes?.name ?? ""),
cells,

@@ -53,0 +53,0 @@ colInfo,

export type AbstractSheet = {
readonly sheets: ReadonlyArray<Sheet>;
readonly styles?: Styles;
readonly name?: string;
};

@@ -6,0 +5,0 @@ export type Sheet = {

{
"name": "abstract-sheet",
"version": "0.0.14",
"version": "0.0.15",
"description": "Abstract sheet",

@@ -32,3 +32,3 @@ "author": "Divid AB <info@divid.se>",

},
"gitHead": "dbb831420cd3951ae33bd7fc28b4ae03714389bb"
"gitHead": "44392cdca5d3899ec402c289ca9ee530d8bec259"
}

@@ -19,25 +19,20 @@ import * as XLSX from "xlsx-js-style";

export function toCsv(
abstractSheets: ReadonlyArray<AbstractSheet>,
options?: CsvOptions
): ReadonlyArray<ReadonlyArray<CsvFile>> {
return (abstractSheets as Array<AbstractSheet>).map((as) => {
const styles = Object.fromEntries(as.styles?.map((s) => [s.name, createStyle(s)]) ?? []);
const mappedOptions: XLSX.Sheet2CSVOpts | undefined = options
? {
FS: options.separator,
RS: options.rowSeparator,
strip: options.noTrailingSeparator,
blankrows: options.blankRows,
skipHidden: options.skipHidden,
forceQuotes: options.forceQuotes,
rawNumbers: options.rawNumber,
dateNF: options.dateFormat,
}
: undefined;
export function toCsv(as: AbstractSheet, options?: CsvOptions): ReadonlyArray<CsvFile> {
const styles = Object.fromEntries(as.styles?.map((s) => [s.name, createStyle(s)]) ?? []);
const mappedOptions: XLSX.Sheet2CSVOpts | undefined = options
? {
FS: options.separator,
RS: options.rowSeparator,
strip: options.noTrailingSeparator,
blankrows: options.blankRows,
skipHidden: options.skipHidden,
forceQuotes: options.forceQuotes,
rawNumbers: options.rawNumber,
dateNF: options.dateFormat,
}
: undefined;
return as.sheets.map(
(s): CsvFile => ({ name: s.name, csv: XLSX.utils.sheet_to_csv(xlsxWorkSheet(s, styles), mappedOptions) })
);
}) as unknown as ReadonlyArray<ReadonlyArray<CsvFile>>;
return as.sheets.map(
(s): CsvFile => ({ name: s.name, csv: XLSX.utils.sheet_to_csv(xlsxWorkSheet(s, styles), mappedOptions) })
);
}

@@ -6,14 +6,14 @@ import * as XLSX from "xlsx-js-style";

export function toXlsx(...abstractSheets: ReadonlyArray<AbstractSheet>): Buffer {
export function toXlsx(as: AbstractSheet): Buffer {
const sheets: Record<string, XLSX.WorkSheet> = {};
const sheetNames = Array<string>();
for (const as of abstractSheets) {
const styles = Object.fromEntries(as.styles?.map((s) => [s.name, createStyle(s)]) ?? []);
for (const s of as.sheets) {
sheetNames.push(s.name);
sheets[s.name] = xlsxWorkSheet(s, styles);
}
const styles = Object.fromEntries(as.styles?.map((s) => [s.name, createStyle(s)]) ?? []);
for (const s of as.sheets) {
sheetNames.push(s.name);
sheets[s.name] = xlsxWorkSheet(s, styles);
}
const wb: XLSX.WorkBook = { Sheets: sheets, SheetNames: Object.keys(sheets) };
return XLSX.write(wb, { bookType: "xlsx", bookSST: false, type: "buffer" });
}

@@ -17,10 +17,6 @@ import {

export const abstractSheetXml = (
template: string,
data: any,
partials: Record<string, string>,
sheetPrefix?: string
): AbstractSheet => abstractSheetOfXml(parseMustacheXml(template, data, partials)[0]!, sheetPrefix) as AbstractSheet;
export const abstractSheetXml = (template: string, data: any, partials: Record<string, string>): AbstractSheet =>
abstractSheetOfXml(parseMustacheXml(template, data, partials)[0]!) as AbstractSheet;
export function abstractSheetOfXml(el: XmlElement, sheetPrefix?: string): unknown {
export function abstractSheetOfXml(el: XmlElement): unknown {
const children = Array<unknown>();

@@ -30,3 +26,3 @@ const childElements = Array<XmlElement>();

if (child.tagName !== undefined) {
children.push(abstractSheetOfXml(child, sheetPrefix));
children.push(abstractSheetOfXml(child));
childElements.push(child);

@@ -62,3 +58,3 @@ }

return {
name: `${sheetPrefix ?? ""}${((el.attributes as Partial<Record<keyof Sheet, unknown>>)?.name ?? "") as string}`,
name: ((el.attributes as Partial<Record<keyof Sheet, unknown>>)?.name ?? "") as string,
cells,

@@ -65,0 +61,0 @@ colInfo,

export type AbstractSheet = {
readonly sheets: ReadonlyArray<Sheet>;
readonly styles?: Styles;
readonly name?: string;
};

@@ -6,0 +5,0 @@

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

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