Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ npm-debug.log
package-lock.json
.idea/
.nyc_output
sync-test
!sync/*
7 changes: 0 additions & 7 deletions .npmignore

This file was deleted.

46 changes: 46 additions & 0 deletions mmkal-mopub.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// run with `npx mopub --config mmkal-mopub.mjs`
export default {
async transformPackage({helpers}) {
await helpers.editJsonFile('package.json', packageJson => {
packageJson.name = '@mmkal/jsonata'
packageJson.description = 'JSON query and transformation language. Can run synchronously or asynchronously.'
})

await helpers.editFile('README.md', readme => {
const dedent = (s) => s.replaceAll('\n ', '\n').trim()
const [beginning, header1, middle, header2, end] = readme.split(/(## Installation|## More information)/).map(s => s.trim())
return [
beginning,
header1,
dedent(`
- \`npm install @mmkal/jsonata\`

## Quick start

Presumably you are using \`@mmkal/jsonata\` rather than the upstream [jsonata](https://npmjs.com/package/jsonata) because you want the synchronous API. Here's how you use it:

In Node.js:

\`\`\`javascript
const jsonata = require('@mmkal/jsonata/sync');

const data = {
example: [
{value: 4},
{value: 7},
{value: 13}
]
};

const expression = jsonata('$sum(example.value)');
const result = expression.evaluate(data); // returns 24
\`\`\`

Background: this package comes from [jsonata-js/jsonata#758](https://github.com/jsonata-js/jsonata/pull/758), which was opened after discussion in [jsonata-js/jsonata#733](https://github.com/jsonata-js/jsonata/issues/733).
`),
header2,
end
].join('\n\n')
})
},
}
24 changes: 21 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,35 @@
"name": "jsonata",
"version": "2.1.0",
"description": "JSON query and transformation language",
"module": "jsonata.js",
"main": "jsonata.js",
"typings": "jsonata.d.ts",
"sideEffects": false,
"files": [
"*.js",
"*.d.ts",
"src",
"sync"
],
"exports": {
".": {
"types": "./jsonata.d.ts",
"import": "./jsonata.js",
"require": "./jsonata.js"
},
"./sync": {
"types": "./sync/jsonata.d.ts",
"import": "./sync/jsonata.js",
"require": "./sync/jsonata.js"
}
},
"homepage": "http://jsonata.org/",
"repository": {
"type": "git",
"url": "https://github.com/jsonata-js/jsonata.git"
},
"scripts": {
"syncify": "node scripts/syncify.js && git diff --exit-code",
"pretest": "npm run lint",
"mocha": "nyc ./node_modules/mocha/bin/_mocha -- \"test/**/*.js\"",
"mocha-sync": "./node_modules/mocha/bin/_mocha -- \"sync-test/**/*.js\"",
"test": "npm run mocha",
"posttest": "npm run check-coverage && npm run browserify && npm run minify && npm run build-es5",
"build-es5": "npm run mkdir-dist && npm run regenerator && npm run browserify-es5 && npm run minify-es5",
Expand Down
Loading