-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
76 changed files
with
1,420 additions
and
3,277 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,14 @@ | ||
// @ts-nocheck | ||
/** | ||
* @callback module:@citation-js/core.Cite~asyncCallback | ||
* @param {Cite} data - Cite object | ||
*/ | ||
|
||
/** | ||
* @access public | ||
* @memberof module:@citation-js/core.Cite | ||
* | ||
* @param {module:@citation-js/core~InputData} data - input data | ||
* @param {module:@citation-js/core~InputOptions} [options={}] - cite options | ||
* @param {module:@citation-js/core.Cite~asyncCallback} [callback] - if not given, function returns promise. | ||
* | ||
* @return {Promise<module:@citation-js/core.Cite>} if callback is omitted, returns a promise | ||
*/ | ||
function async(data, options, callback) { | ||
if (typeof options === 'function' && !callback) { | ||
callback = options | ||
options = undefined | ||
} | ||
|
||
const promise = new this().setAsync(data, options) | ||
|
||
if (typeof callback === 'function') { | ||
promise.then(callback) | ||
return undefined | ||
} else { | ||
return promise | ||
} | ||
} | ||
|
||
export default async |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,24 @@ | ||
//@ts-nocheck | ||
// @ts-nocheck | ||
import * as log from './log.js' | ||
import * as options from './options.js' | ||
import * as set from './set.js' | ||
import * as sort from './sort.js' | ||
import * as get from './get.js' | ||
import * as staticMethods from './static.js' | ||
|
||
/** | ||
* Create a `Cite` object with almost any kind of data, and manipulate it with its default methods. | ||
* | ||
* @access public | ||
* @constructor Cite | ||
* @memberof module:@citation-js/core | ||
* | ||
* @param {module:@citation-js/core~InputData} data - Input data | ||
* @param {module:@citation-js/core~InputOptions} [options={}] - Input options | ||
*/ | ||
function Cite(data, options = {}) { | ||
// Making it Scope-Safe | ||
if (!(this instanceof Cite)) { | ||
return new Cite(data, options) | ||
} | ||
|
||
/** | ||
* The default options for the output. See [input options](../#cite.in.options) | ||
* | ||
* @access protected | ||
* @memberof module:@citation-js/core.Cite# | ||
* | ||
* @var {module:@citation-js/core~InputOptions} _options | ||
*/ | ||
this._options = options | ||
|
||
/** | ||
* The saved-images-log | ||
* | ||
* @access protected | ||
* @memberof module:@citation-js/core.Cite# | ||
* | ||
* @var {Array<Array<String>>} log | ||
*/ | ||
this.log = [] | ||
|
||
/** | ||
* The parsed data | ||
* | ||
* @access protected | ||
* @memberof module:@citation-js/core.Cite# | ||
* | ||
* @var {Array<module:@citation-js/core~CSL>} data | ||
*/ | ||
this.data = [] | ||
|
||
// Modified citation-js to accept an array of objects | ||
// Use add instead of set to retain previous data | ||
data.forEach((d) => { | ||
this.add(d, options) | ||
}) | ||
// this.set(data, options) | ||
this.set(data, options) | ||
this.options(options) | ||
|
||
return this | ||
} | ||
|
||
Object.assign(Cite.prototype, log, options, set, sort, get) | ||
|
||
Cite.prototype[Symbol.iterator] = function* () { | ||
yield* this.data | ||
} | ||
|
||
Object.assign(Cite, staticMethods) | ||
|
||
export default Cite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,16 @@ | ||
import { validateOutputOptions as validate } from './validate.js' | ||
|
||
/** | ||
* @memberof module:@citation-js/core.Cite# | ||
* | ||
* @constant {module:@citation-js/core~OutputOptions} defaultOptions - default output options | ||
*/ | ||
const defaultOptions = { format: 'real', type: 'json', style: 'csl', lang: 'en-US' } | ||
|
||
/** | ||
* Change the default options of a `Cite` object. | ||
* | ||
* @memberof Cite# | ||
* | ||
* @param {module:@citation-js/core~OutputOptions} options - The options for the output | ||
* @param {Boolean} [log=false] - Show this call in the log | ||
* | ||
* @return {module:@citation-js/core.Cite} The updated parent object | ||
*/ | ||
const defaultOptions = { | ||
format: 'real', | ||
type: 'json', | ||
style: 'csl', | ||
lang: 'en-US', | ||
} | ||
function options(options, log) { | ||
validate(options) | ||
|
||
if (log) { | ||
this.save() | ||
} | ||
|
||
Object.assign(this._options, options) | ||
|
||
return this | ||
} | ||
|
||
export { options, defaultOptions } |
Oops, something went wrong.