https://github.com/food-static-data/sd
Food static data wrapper
https://github.com/food-static-data/sd
food-technology ingredients json measurements recipes
Last synced: 8 months ago
JSON representation
Food static data wrapper
- Host: GitHub
- URL: https://github.com/food-static-data/sd
- Owner: Food-Static-Data
- License: gpl-3.0
- Created: 2019-02-08T00:34:50.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-09-27T09:36:22.000Z (over 1 year ago)
- Last Synced: 2025-01-29T10:46:38.338Z (over 1 year ago)
- Topics: food-technology, ingredients, json, measurements, recipes
- Language: JavaScript
- Homepage:
- Size: 62.4 MB
- Stars: 9
- Watchers: 5
- Forks: 13
- Open Issues: 56
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README

Static food wrapper module
[](https://travis-ci.org/GroceriStar/sd)
[](https://standardjs.com)
[](https://coveralls.io/r/GroceriStar/sd)
[](https://codeclimate.com/github/GroceriStar/sd/maintainability)
[](https://codeclimate.com/github/GroceriStar/sd/test_coverage)
[](https://npmjs.org/package/@groceristar/sd-wrapper "View this project on npm")
# Table of Contents
- [Quick Start](#quick-start)
- [What's included](#installation)
- [Bugs and feature requests](#code-example)
- [Documentation](#tests)
- [Contributors](#contributors)
## Quick Start
Several quick start options are available:
- Clone the repo: `git clone https://github.com/GroceriStar/sd.git`
- Install with npm: `npm install @groceristar/sd-wrapper`
- Install with yarn: `yarn add @groceristar/sd-wrapper`
## What's included
Within the download you'll find the following directories and files, logically grouping common assets and providing both compiled and minified variations. You'll see something like this:
```
.
├── docs
│ └── Readme.md # Secondary information about project
/- update with our new folder changes /
└──package # Folder contains src folder and configuration files
├── dist # Output folder for [NPM compiler] commands
├──src # Folder with static JSON files. WTF what is going on here
└── test
package.json
babel.config.js
jest.config.js
rollup.config.js
jsonlint.config.js
lint-staged.config.js
.eslintrc.json
.huskyrc.js
.snyk
CONTRIBUTING.md
.gitignore
README.md
travis.yml
renovate.json
SECURITY.md
LICENSE
```
We provide compiled JS, as well as compiled and minified JS.
https://github.com/Food-Static-Data/sd/projects/1
## Bugs and feature requests
Have a bug or a feature request? Please first read the issue guidelines and search for existing and closed issues. If your problem or idea is not addressed yet, please open a new issue.
## Documentation
Are we have documentation? If no, it should be written
### NPM commands
#### Compiler commands
- `yarn bundle` or `npm run bundle`: in folder `dist` will be compiled three files with `.cjs`, `es.js`, `iife.js` extensions. Files contain output data of recipes, departments, etc.
- `yarn dev` or `npm run dev`: compile and watch for changes (run watcher)
- `jest`: Run tests through project
- `npm run jsonlint` or `yarn jsonlint`: validate JSON output files
- `npm run code-fix` or `yarn code-fix`: run [standard](https://www.npmjs.com/package/standard) linter with write permissions
#### Generator commands
- `npm run generate` or `yarn generate`: generate all recipes in folder `dist`.
More detailed information [here](#how-to-generate)
#### Parser commands
- `npm run parseCsv` or `yarn parseCsv` : parse from csv to json Food Composition
## How to generate additional files
To run generator (it will run in writeFile.js function writeFiles()) `npm run generateFiles` to know if writing is success in console you will see `file generated successfully!` it will write multiple files.
In function `writeFiles()` should be array of files. In array config of objects.
First property in object should be `name` and value filename, the second `data` and in value set function that returns data.
By default generating files happens in `/src/data`
Also you can write one file using function `writeFile()` just give it two parameters first - `path`, second `data` that will need to write. Data should be object and JSON format.
## How to split json into single elements
**--- update information about how to use generator module ---**
```
const writeFile = require('path to sd/generator/writeFile.js')
var path = "/path/of/the/file/"
writeFile.splitObject(path, 'filename.json', 1, writeFile.combineObject, ['key1', 'key2'])
```
**getFileInfo('path_of_directory')** - returns a list of files present in the directory.
Sample Output:
```
[ 'some_file_abc.json',
'some_file_pqr.json',
'some_file_xyz.json' ]
```
**getFileInfo('path_of_directory',1)** - returns contents of all json files present in the directory.
Sample Output:
```
[ { departments: [ 'Other' ],
id: 14,
name: 'number-four9',
img: false,
desc: false,
slug: false },
{ departments: [ 'Other' ],
id: 7,
name: 'Rabel Dietitian',
img: false,
desc: false,
slug: false } ]
```
**getFileInfo('path_of_directory',1,'fileName')** - returns content of the given file from the directory.
Sample Output:
```
{ departments: [ 'Other' ],
id: 14,
name: 'number-four9',
img: false,
desc: false,
slug: false }
```
## Contributors
@vadim9999, @atherdon, @wahaj-47, @tihaami, @EbrahimKreem, @elnur004, @hirdbluebird, @Beni03, @Edebo, @uniyalprashant9
#### publish at npm
```
- npm login
- - username
- - password
- - email
- npm version patch
- git commit
- npm publish
- git push --tags (if tag was not created - https://www.atlassian.com/git/tutorials/inspecting-a-repository/git-tag)
```
## Support
**Bugs and requests**: submit them through the project's issues tracker.
[](https://github.com/GroceriStar/sd/issues)