-
-
Notifications
You must be signed in to change notification settings - Fork 8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Idiomatic API #1331
Comments
There are three independent but related questions embedded here:
When we first started, MIT license was popular in the JS community and we wanted to stick with that. The project leaned on ECMA-376, which was an open standard and had no encumbrances. XLS and other related specs are not; they are covered under the Microsoft "Open Specifications Promise", which is essentially a covenant not to sue. As a result, we kept them separate: If you're interested in the history of open source pertaining to spreadsheets, read https://github.com/kennethreitz/tablib/issues/114
The API is more or less how you would design a C API, which reflects our personal histories. In most C styles snake_case is preferred, and C libraries generally follow the "bag of static functions" style.
When we first started, back when ES5 was the latest version of the language specification, there was no easy way to serialize and deserialize objects created with a constructor. Plain objects have the advantage of JSON stringification, which lets you do cool things like serialize the entire workbook object and send it from the main browser thread to a Web Worker in the web browser. The If you're starting in 2018 and only planning to create basic files in node, there are definitely more idiomatic styles. Object-mode streams and generator functions make for even neater APIs. But for the varied use cases the most flexible approach is preferable. |
Thank you for the detailed explanation! |
I've been toying around with this library for the past 24 hours, and while I appreciate the amazing effort that went into it, I wonder if the API could be made to be more similar to that of other libraries in the JavaScript ecosystem.
What do I mean? Imagine you don't know anything about SheetJS, and want to create a workbook with a worksheet in it. How would you name the methods to do that? Would you come up with this?
This API seems very peculiar to me. Nevermind that JS favors camelCase to underscore_case, calling static methods on XLSX is unwieldy. I would find something like this a lot more idiomatic:
UPDATE: I've just discovered exceljs. The API is very similar to what I've proposed above:
new
to create a workbook,workbook.addWorksheet
,worksheet.addRow
.The text was updated successfully, but these errors were encountered: