https://github.com/zotero/utilities
Zotero utility code
https://github.com/zotero/utilities
Last synced: about 1 year ago
JSON representation
Zotero utility code
- Host: GitHub
- URL: https://github.com/zotero/utilities
- Owner: zotero
- License: other
- Created: 2021-06-23T09:15:02.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-10-16T04:40:16.000Z (over 1 year ago)
- Last Synced: 2024-10-17T19:46:49.985Z (over 1 year ago)
- Language: JavaScript
- Size: 310 KB
- Stars: 11
- Watchers: 10
- Forks: 21
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
README
# Zotero Utilities
Zotero utility code common across various codebases such as the Zotero client,
Zotero translation architecture and others.
Item utility functions require:
- Calling `Zotero.Schema.init(json)` with the JSON from `schema.json` from Zotero schema repo
- Calling `Zotero.Date.init(json)` with the JSON from `resource/dateFormats.json`
- Loading `resource/zoteroTypeSchemaData.js` before `cachedTypes.js` or in Node.js running
```js
let CachedTypes = require('./cachedTypes')
CachedTypes.setTypeSchema(require('./resource/zoteroTypeSchemaData'))
```
- Implementing `Zotero.localeCompare()`; a simple implementation would be
```js
let collator = new Intl.Collator(['en-US'], {
numeric: true,
sensitivity: 'base'
});
Zotero.localeCompare = (a, b) => collator.compare(a, b);
```
Please bundle the [Zotero schema](https://github.com/zotero/zotero-schema) file with your repository, do not load it remotely.
To run tests:
```bash
git clone --recursive https://github.com/zotero/utilities.git
cd utilities
npm i
npm test
```