This is a JavaScript utility module that represents a category taxonomy (nested list)
for places people care about in the world, aka Points of Interest (POIs).
Categories represent the place type, for example a Starbucks is a coffee_shop
.
yarn add @streetcredlabs/categories
or
npm i --save @streetcredlabs/categories
// using CommonJS
const { findById } = require('@streetcredlabs/categories');
// using ES6
import { findById } from '@streetcredlabs/categories';
This function allows the client to look up the category object by its id. Categories may be nested.
import { findById } from '@streetcredlabs/categories';
const category = findById(1);
{
"id": 1,
"name": "Arts & Entertainment",
"icon": "theatre",
"categories": [ <category> ]
}
Returns the entire categories array.
import { dump } from '@streetcredlabs/categories';
const categories = dump();
[
{
"id": 1,
"name": "Arts & Entertainment",
"icon": "theatre",
"categories": [...]
},
...
]
Pull requests are warmly welcomed.
git clone git@github.com:streetcredlabs/categories.git && cd categories
yarn
or
npm i
yarn test-watch
or
npm run test-watch
yarn test
or
npm run test
yarn start
or
npm run start
yarn build
or
npm run build
- Rollup-plugin-json, which allows Rollup to import data from a JSON file.
- Rollup-plugin-node-resolve, which allows us to load third-party modules in node_modules.
- Rollup-plugin-commonjs, which coverts CommonJS modules to ES6, which stops them from breaking Rollup.
- Babel, which transpiles new features of JavaScript (ES6/ES2015 and so on) into ES5
- Represents the next generation of build tools in terms of its performance (build time), intermediate configuration (less complicated than webpack but more involved than Parcel), and optional but out-of-the-box features likes source maps, and not using a .babelrc.
- Rich ecosystem of plugins for file loading/dev servers
- Code splitting
- Tree shaking (live code inclusion / dead code elimination)
- esnext:main entry in package.json to import es2015+ (renamed to ‘module’)
- Scope hoisting
- Simple API
- Since codebase is ES2015 modules and we're making something to be used by other people
Reference:
Rollup v. Webpack v. Parcel by Adam Gerard