New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

astrocite

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

astrocite - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

lib/bibtex/constants.js

6

lib/bibtex/index.js
"use strict";
console.log('hello world');
Object.defineProperty(exports, "__esModule", { value: true });
var AST = require("./grammar");
exports.AST = AST;
var parser_1 = require("./parser");
exports.parse = parser_1.default;
"use strict";
console.log('hello world!');
var bibtex = require("./bibtex");
var ris = require("./ris");
module.exports = {
bibtex: bibtex,
ris: ris,
};

344

lib/ris/grammar.js

@@ -112,9 +112,11 @@ /*

return {
type: 'File',
references: r,
kind: 'File',
loc: location(),
children: r,
};
}, peg$c1 = function (kind, fields) {
}, peg$c1 = function (type, fields) {
return {
type: 'Reference',
kind: kind,
kind: 'Entry',
loc: location(),
type: type,
properties: fields,

@@ -125,6 +127,7 @@ };

type: 'Property',
loc: location(),
key: k,
value: v,
};
}, peg$c3 = "ER", peg$c4 = peg$literalExpectation("ER", false), peg$c5 = /^[A-Z0-9]/, peg$c6 = peg$classExpectation([["A", "Z"], ["0", "9"]], false, false), peg$c7 = function (k) { return k.join(''); }, peg$c8 = /^[^\r\n]/, peg$c9 = peg$classExpectation(["\r", "\n"], true, false), peg$c10 = function (line) { return line.join(''); }, peg$c11 = "TY", peg$c12 = peg$literalExpectation("TY", false), peg$c13 = function (v) { return v; }, peg$c14 = "-", peg$c15 = peg$literalExpectation("-", false), peg$c16 = /^[\r\n]/, peg$c17 = peg$classExpectation(["\r", "\n"], false, false), peg$c18 = peg$otherExpectation("Field Separator"), peg$c19 = peg$otherExpectation("Mandatory Whitespace"), peg$c20 = /^[ \t\r\n]/, peg$c21 = peg$classExpectation([" ", "\t", "\r", "\n"], false, false), peg$c22 = peg$otherExpectation("Optional Whitespace"), peg$currPos = 0, peg$savedPos = 0, peg$posDetailsCache = [{ line: 1, column: 1 }], peg$maxFailPos = 0, peg$maxFailExpected = [], peg$silentFails = 0, peg$resultsCache = {}, peg$result;
}, peg$c3 = "ER", peg$c4 = peg$literalExpectation("ER", false), peg$c5 = /^[A-Z0-9]/, peg$c6 = peg$classExpectation([["A", "Z"], ["0", "9"]], false, false), peg$c7 = function (k) { return k; }, peg$c8 = /^[^\r\n]/, peg$c9 = peg$classExpectation(["\r", "\n"], true, false), peg$c10 = function (line) { return line; }, peg$c11 = "-", peg$c12 = peg$literalExpectation("-", false), peg$c13 = "TY", peg$c14 = peg$literalExpectation("TY", false), peg$c15 = function (v) { return v; }, peg$c16 = /^[\r\n]/, peg$c17 = peg$classExpectation(["\r", "\n"], false, false), peg$c18 = peg$otherExpectation("Mandatory Horizontal Whitespace"), peg$c19 = /^[ \t]/, peg$c20 = peg$classExpectation([" ", "\t"], false, false), peg$c21 = peg$otherExpectation("Optional Horizontal Whitespace"), peg$c22 = peg$otherExpectation("Mandatory Vertical Whitespace"), peg$c23 = peg$otherExpectation("Optional Vertical Whitespace"), peg$c24 = peg$otherExpectation("Mandatory Whitespace"), peg$c25 = /^[ \t\n\r]/, peg$c26 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false), peg$c27 = peg$otherExpectation("Optional Whitespace"), peg$currPos = 0, peg$savedPos = 0, peg$posDetailsCache = [{ line: 1, column: 1 }], peg$maxFailPos = 0, peg$maxFailExpected = [], peg$silentFails = 0, peg$resultsCache = {}, peg$result;
if ("startRule" in options) {

@@ -227,3 +230,3 @@ if (!(options.startRule in peg$startRuleFunctions)) {

var s0, s1, s2, s3;
var key = peg$currPos * 11 + 0, cached = peg$resultsCache[key];
var key = peg$currPos * 15 + 0, cached = peg$resultsCache[key];
if (cached) {

@@ -237,7 +240,7 @@ peg$currPos = cached.nextPos;

s2 = [];
s3 = peg$parseReference();
s3 = peg$parseEntry();
if (s3 !== peg$FAILED) {
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parseReference();
s3 = peg$parseEntry();
}

@@ -272,5 +275,5 @@ }

}
function peg$parseReference() {
function peg$parseEntry() {
var s0, s1, s2, s3;
var key = peg$currPos * 11 + 1, cached = peg$resultsCache[key];
var key = peg$currPos * 15 + 1, cached = peg$resultsCache[key];
if (cached) {

@@ -320,3 +323,3 @@ peg$currPos = cached.nextPos;

var s0, s1, s2, s3, s4;
var key = peg$currPos * 11 + 2, cached = peg$resultsCache[key];
var key = peg$currPos * 15 + 2, cached = peg$resultsCache[key];
if (cached) {

@@ -329,3 +332,3 @@ peg$currPos = cached.nextPos;

if (s1 !== peg$FAILED) {
s2 = peg$parseSEP();
s2 = peg$parsePropertySeparator();
if (s2 !== peg$FAILED) {

@@ -363,4 +366,4 @@ s3 = peg$parsePropertyValue();

function peg$parsePropertyKey() {
var s0, s1, s2, s3;
var key = peg$currPos * 11 + 3, cached = peg$resultsCache[key];
var s0, s1, s2, s3, s4;
var key = peg$currPos * 15 + 3, cached = peg$resultsCache[key];
if (cached) {

@@ -392,9 +395,10 @@ peg$currPos = cached.nextPos;

if (s1 !== peg$FAILED) {
s2 = [];
s2 = peg$currPos;
s3 = [];
if (peg$c5.test(input.charAt(peg$currPos))) {
s3 = input.charAt(peg$currPos);
s4 = input.charAt(peg$currPos);
peg$currPos++;
}
else {
s3 = peg$FAILED;
s4 = peg$FAILED;
if (peg$silentFails === 0) {

@@ -404,11 +408,11 @@ peg$fail(peg$c6);

}
if (s3 !== peg$FAILED) {
while (s3 !== peg$FAILED) {
s2.push(s3);
if (s4 !== peg$FAILED) {
while (s4 !== peg$FAILED) {
s3.push(s4);
if (peg$c5.test(input.charAt(peg$currPos))) {
s3 = input.charAt(peg$currPos);
s4 = input.charAt(peg$currPos);
peg$currPos++;
}
else {
s3 = peg$FAILED;
s4 = peg$FAILED;
if (peg$silentFails === 0) {

@@ -421,4 +425,10 @@ peg$fail(peg$c6);

else {
s2 = peg$FAILED;
s3 = peg$FAILED;
}
if (s3 !== peg$FAILED) {
s2 = input.substring(s2, peg$currPos);
}
else {
s2 = s3;
}
if (s2 !== peg$FAILED) {

@@ -442,4 +452,4 @@ peg$savedPos = s0;

function peg$parsePropertyValue() {
var s0, s1, s2;
var key = peg$currPos * 11 + 4, cached = peg$resultsCache[key];
var s0, s1, s2, s3;
var key = peg$currPos * 15 + 4, cached = peg$resultsCache[key];
if (cached) {

@@ -450,9 +460,10 @@ peg$currPos = cached.nextPos;

s0 = peg$currPos;
s1 = [];
s1 = peg$currPos;
s2 = [];
if (peg$c8.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);
s3 = input.charAt(peg$currPos);
peg$currPos++;
}
else {
s2 = peg$FAILED;
s3 = peg$FAILED;
if (peg$silentFails === 0) {

@@ -462,10 +473,10 @@ peg$fail(peg$c9);

}
while (s2 !== peg$FAILED) {
s1.push(s2);
while (s3 !== peg$FAILED) {
s2.push(s3);
if (peg$c8.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);
s3 = input.charAt(peg$currPos);
peg$currPos++;
}
else {
s2 = peg$FAILED;
s3 = peg$FAILED;
if (peg$silentFails === 0) {

@@ -476,2 +487,8 @@ peg$fail(peg$c9);

}
if (s2 !== peg$FAILED) {
s1 = input.substring(s1, peg$currPos);
}
else {
s1 = s2;
}
if (s1 !== peg$FAILED) {

@@ -485,5 +502,48 @@ peg$savedPos = s0;

}
function peg$parsePropertySeparator() {
var s0, s1, s2, s3;
var key = peg$currPos * 15 + 5, cached = peg$resultsCache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
s0 = peg$currPos;
s1 = peg$parse_h();
if (s1 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 45) {
s2 = peg$c11;
peg$currPos++;
}
else {
s2 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c12);
}
}
if (s2 !== peg$FAILED) {
s3 = peg$parse_h();
if (s3 !== peg$FAILED) {
s1 = [s1, s2, s3];
s0 = s1;
}
else {
peg$currPos = s0;
s0 = peg$FAILED;
}
}
else {
peg$currPos = s0;
s0 = peg$FAILED;
}
}
else {
peg$currPos = s0;
s0 = peg$FAILED;
}
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseSTART() {
var s0, s1, s2, s3, s4;
var key = peg$currPos * 11 + 5, cached = peg$resultsCache[key];
var key = peg$currPos * 15 + 6, cached = peg$resultsCache[key];
if (cached) {

@@ -494,4 +554,4 @@ peg$currPos = cached.nextPos;

s0 = peg$currPos;
if (input.substr(peg$currPos, 2) === peg$c11) {
s1 = peg$c11;
if (input.substr(peg$currPos, 2) === peg$c13) {
s1 = peg$c13;
peg$currPos += 2;

@@ -502,7 +562,7 @@ }

if (peg$silentFails === 0) {
peg$fail(peg$c12);
peg$fail(peg$c14);
}
}
if (s1 !== peg$FAILED) {
s2 = peg$parseSEP();
s2 = peg$parsePropertySeparator();
if (s2 !== peg$FAILED) {

@@ -514,3 +574,3 @@ s3 = peg$parsePropertyValue();

peg$savedPos = s0;
s1 = peg$c13(s3);
s1 = peg$c15(s3);
s0 = s1;

@@ -542,3 +602,3 @@ }

var s0, s1, s2, s3, s4;
var key = peg$currPos * 11 + 6, cached = peg$resultsCache[key];
var key = peg$currPos * 15 + 7, cached = peg$resultsCache[key];
if (cached) {

@@ -560,6 +620,6 @@ peg$currPos = cached.nextPos;

if (s1 !== peg$FAILED) {
s2 = peg$parse_();
s2 = peg$parse_h();
if (s2 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 45) {
s3 = peg$c14;
s3 = peg$c11;
peg$currPos++;

@@ -570,3 +630,3 @@ }

if (peg$silentFails === 0) {
peg$fail(peg$c15);
peg$fail(peg$c12);
}

@@ -604,3 +664,3 @@ }

var s0;
var key = peg$currPos * 11 + 7, cached = peg$resultsCache[key];
var key = peg$currPos * 15 + 8, cached = peg$resultsCache[key];
if (cached) {

@@ -620,4 +680,48 @@ peg$currPos = cached.nextPos;

}
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parse_h() {
var s0, s1;
var key = peg$currPos * 15 + 9, cached = peg$resultsCache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
peg$silentFails++;
s0 = [];
if (peg$c19.test(input.charAt(peg$currPos))) {
s1 = input.charAt(peg$currPos);
peg$currPos++;
}
else {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c20);
}
}
if (s1 !== peg$FAILED) {
while (s1 !== peg$FAILED) {
s0.push(s1);
if (peg$c19.test(input.charAt(peg$currPos))) {
s1 = input.charAt(peg$currPos);
peg$currPos++;
}
else {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c20);
}
}
}
}
else {
s0 = peg$FAILED;
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s0 = null;
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c18);
}
}

@@ -627,5 +731,5 @@ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };

}
function peg$parseSEP() {
var s0, s1, s2, s3;
var key = peg$currPos * 11 + 8, cached = peg$resultsCache[key];
function peg$parse__h() {
var s0, s1;
var key = peg$currPos * 15 + 10, cached = peg$resultsCache[key];
if (cached) {

@@ -636,33 +740,71 @@ peg$currPos = cached.nextPos;

peg$silentFails++;
s0 = peg$currPos;
s1 = peg$parse_();
if (s1 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 45) {
s2 = peg$c14;
s0 = [];
if (peg$c19.test(input.charAt(peg$currPos))) {
s1 = input.charAt(peg$currPos);
peg$currPos++;
}
else {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c20);
}
}
while (s1 !== peg$FAILED) {
s0.push(s1);
if (peg$c19.test(input.charAt(peg$currPos))) {
s1 = input.charAt(peg$currPos);
peg$currPos++;
}
else {
s2 = peg$FAILED;
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c15);
peg$fail(peg$c20);
}
}
if (s2 !== peg$FAILED) {
s3 = peg$parse_();
if (s3 !== peg$FAILED) {
s1 = [s1, s2, s3];
s0 = s1;
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c21);
}
}
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parse_v() {
var s0, s1;
var key = peg$currPos * 15 + 11, cached = peg$resultsCache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
peg$silentFails++;
s0 = [];
if (peg$c16.test(input.charAt(peg$currPos))) {
s1 = input.charAt(peg$currPos);
peg$currPos++;
}
else {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c17);
}
}
if (s1 !== peg$FAILED) {
while (s1 !== peg$FAILED) {
s0.push(s1);
if (peg$c16.test(input.charAt(peg$currPos))) {
s1 = input.charAt(peg$currPos);
peg$currPos++;
}
else {
peg$currPos = s0;
s0 = peg$FAILED;
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c17);
}
}
}
else {
peg$currPos = s0;
s0 = peg$FAILED;
}
}
else {
peg$currPos = s0;
s0 = peg$FAILED;

@@ -674,3 +816,3 @@ }

if (peg$silentFails === 0) {
peg$fail(peg$c18);
peg$fail(peg$c22);
}

@@ -681,5 +823,47 @@ }

}
function peg$parse__v() {
var s0, s1;
var key = peg$currPos * 15 + 12, cached = peg$resultsCache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
peg$silentFails++;
s0 = [];
if (peg$c16.test(input.charAt(peg$currPos))) {
s1 = input.charAt(peg$currPos);
peg$currPos++;
}
else {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c17);
}
}
while (s1 !== peg$FAILED) {
s0.push(s1);
if (peg$c16.test(input.charAt(peg$currPos))) {
s1 = input.charAt(peg$currPos);
peg$currPos++;
}
else {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c17);
}
}
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c23);
}
}
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parse_() {
var s0, s1;
var key = peg$currPos * 11 + 9, cached = peg$resultsCache[key];
var key = peg$currPos * 15 + 13, cached = peg$resultsCache[key];
if (cached) {

@@ -691,3 +875,3 @@ peg$currPos = cached.nextPos;

s0 = [];
if (peg$c20.test(input.charAt(peg$currPos))) {
if (peg$c25.test(input.charAt(peg$currPos))) {
s1 = input.charAt(peg$currPos);

@@ -699,3 +883,3 @@ peg$currPos++;

if (peg$silentFails === 0) {
peg$fail(peg$c21);
peg$fail(peg$c26);
}

@@ -706,3 +890,3 @@ }

s0.push(s1);
if (peg$c20.test(input.charAt(peg$currPos))) {
if (peg$c25.test(input.charAt(peg$currPos))) {
s1 = input.charAt(peg$currPos);

@@ -714,3 +898,3 @@ peg$currPos++;

if (peg$silentFails === 0) {
peg$fail(peg$c21);
peg$fail(peg$c26);
}

@@ -727,3 +911,3 @@ }

if (peg$silentFails === 0) {
peg$fail(peg$c19);
peg$fail(peg$c24);
}

@@ -736,3 +920,3 @@ }

var s0, s1;
var key = peg$currPos * 11 + 10, cached = peg$resultsCache[key];
var key = peg$currPos * 15 + 14, cached = peg$resultsCache[key];
if (cached) {

@@ -744,3 +928,3 @@ peg$currPos = cached.nextPos;

s0 = [];
if (peg$c20.test(input.charAt(peg$currPos))) {
if (peg$c25.test(input.charAt(peg$currPos))) {
s1 = input.charAt(peg$currPos);

@@ -752,3 +936,3 @@ peg$currPos++;

if (peg$silentFails === 0) {
peg$fail(peg$c21);
peg$fail(peg$c26);
}

@@ -758,3 +942,3 @@ }

s0.push(s1);
if (peg$c20.test(input.charAt(peg$currPos))) {
if (peg$c25.test(input.charAt(peg$currPos))) {
s1 = input.charAt(peg$currPos);

@@ -766,3 +950,3 @@ peg$currPos++;

if (peg$silentFails === 0) {
peg$fail(peg$c21);
peg$fail(peg$c26);
}

@@ -775,3 +959,3 @@ }

if (peg$silentFails === 0) {
peg$fail(peg$c22);
peg$fail(peg$c27);
}

@@ -778,0 +962,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var fs_1 = require("fs");
var path_1 = require("path");
var parser = require("./grammar");
var file = fs_1.readFileSync(path_1.resolve(__dirname, '../tester.ris'), 'utf-8');
console.log(JSON.stringify(parser.parse(file), null, 4));
var AST = require("./grammar");
exports.AST = AST;
var parser_1 = require("./parser");
exports.parse = parser_1.default;
{
"name": "astrocite",
"version": "0.1.0",
"version": "0.2.0",
"description": "Bibliography file format => AST => CSL JSON",

@@ -13,16 +13,29 @@ "license": "MIT",

"prepush": "npm test && npm run lint",
"test": "npm run build && jest",
"posttest": "npm run lint",
"test": "jest src/**",
"ci": "jest --coverage src/**",
"postci": "npm run lint",
"lint": "tslint -e \"**/*.js\" -p . -t codeFrame",
"prebuild":
"pegjs -o src/bibtex/grammar.js --cache src/bibtex/grammar.pegjs && pegjs -o src/ris/grammar.js --cache src/ris/grammar.pegjs",
"build": "tsc -p ."
"prebuild": "pegjs -o src/bibtex/grammar.js --cache src/bibtex/grammar.pegjs && pegjs -o src/ris/grammar.js --cache src/ris/grammar.pegjs",
"build": "rm -rf lib/* && tsc -p ."
},
"lint-staged": {
"*.{ts,tsx,json}": ["prettier --write", "git add"]
"*.{ts,tsx}": [
"prettier --write",
"git add"
]
},
"files": ["lib/**"],
"keywords": ["CSL", "Citation Style Language", "BibTeX", "AST", "Bibliography", "Citation"],
"files": [
"lib/**"
],
"keywords": [
"CSL",
"Citation Style Language",
"BibTeX",
"AST",
"Bibliography",
"Citation"
],
"devDependencies": {
"@types/node": "^8.0.27",
"@types/jest": "^20.0.8",
"@types/node": "^8.0.28",
"husky": "^0.14.3",

@@ -33,5 +46,25 @@ "jest": "^21.0.2",

"prettier": "^1.6.1",
"ts-jest": "^21.0.0",
"tslint": "^5.7.0",
"typescript": "^2.5.2"
},
"jest": {
"transform": {
"^.+\\.tsx?$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"coverageDirectory": "tmp/coverage",
"collectCoverageFrom": [
"src/**/*.ts",
"!src/**/*.d.ts",
"!src/**/index.ts"
],
"mapCoverage": true,
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"json"
]
}
}

@@ -0,1 +1,3 @@

[![Join the chat at https://gitter.im/astrocite/Lobby](https://badges.gitter.im/astrocite/Lobby.svg)](https://gitter.im/astrocite/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://travis-ci.org/dsifford/astrocite.svg?branch=master)](https://travis-ci.org/dsifford/astrocite) [![codecov](https://codecov.io/gh/dsifford/astrocite/branch/master/graph/badge.svg)](https://codecov.io/gh/dsifford/astrocite)
# astrocite

@@ -22,7 +24,47 @@

**TODO...**
### Modular (smaller bundles)
```js
import { parse } from 'astrocite/bibtex';
// or
var parse = require('astrocite/bibtex').parse;
const input = `
@article{my_article,
title = {Hello world},
journal = "Some Journal"
}
`;
const cslJson = parse(input);
```
### Classic
```js
import * as astrocite from 'astrocite';
// or
var astrocite = require('astrocite');
const input = `
@article{my_article,
title = {Hello world},
journal = "Some Journal"
}
`;
const cslJson = astrocite.bibtex.parse(input);
```
**ASTs are also available if needed.**
```js
import { AST } from 'astrocite/bibtex';
// or
import { AST } from 'astrocite/ris';
// ....etc
```
> **Note:** Examples for each individual AST can be found in the README file of each subdirectory.
## Contributing

@@ -29,0 +71,0 @@

Sorry, the diff of this file is too big to display

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