open-index/open-npm huggingface dataset:
npm package: @moozon/tiny-compiler
Description: tiny compiler for learning
Author: Moozon
Latest version: 0.0.2

# Tiny Compiler

Learn [the-super-tiny-compiler](https://github.com/jamiebuilds/the-super-tiny-compiler).

- [x] tokenizer
- [x] parser
- [x] traverser
- [x] transformer
- [x] codegen
- [x] compiler
npm package: @moped/db-pg
Description: This module provides a method for accessing postgres databases from node.js that is as safe as it possibly can be from SQL injection. It is part of the moped suite of utilities for creating composable configs for building node.js and react apps.
Latest version: 0.0.13

# DB Postgres

This module provides a method for accessing postgres databases from node.js that is as safe as it possibly can be from SQL injection. It is part of the moped suite of utilities for creating composable configs for building node.js and react apps.

This module is designed to be used in conjunction with `@moped/sql`.

## Installation

```
yarn add @moped/db-pg @moped/sql
```

## Usage

```js
const connect = require('@moped/db-pg');

// to use the DATABASE_URL environment variable:
module.exports = connect();

// to pass a database connection inline:
module.exports = connect('my database connection');
```

The connection has three methods:

### query

The query method takes an `SQLQuery` (see `@moped/sql`) and returns a Promise for an array of users.  e.g.

```js
connection.query(
  sql`SELECT * FROM users WHERE name=${'ForbesLindesay'}`
).then(users => users.forEach(user => console.log(user)));
```

If you pass a string, number, or anything else that's not an `SQLQuery` object, we will assume you made a mistake, and return an error to prevent SQL injection.

### task

Task lets you allocate a single connection to multiple queries. In a web application you generally want to allocate one task to each request.

```js
connection.task(async (task) => {
  // you can use `task` here exactly like you used `connection` before
  const users = await task.query(
    sql`SELECT * FROM users WHERE name=${'ForbesLindesay'}`
  );
  users.forEach(user => console.log(user));
});
```

Once the function given to `task` has finished executing (and any returned promise has been resolved) the connection is released back into the pool.

### tx

Transactions are just like tasks, except that they enforce strong transactional consistency between multiple database users.  This comes at a significant cost to performance, but it's by far the easiest way of doing things like ensuring that "the number of tickets people have booked does not exceed the number of available tickets" in a ticketing system (for example).

```js
connection.tx(async (transaction) => {
  // you can use `transaction` here exactly like you used `connection` before
  const users = await transaction.query(
    sql`SELECT * FROM users WHERE name=${'ForbesLindesay'}`
  );
  users.forEach(user => console.log(user));
});
```

## Licence

MIT
npm package: @moped/env
Description: This module helps normalise your environment variables. It is part of the moped suite of utilities for creating composable configs for building node.js and react apps.
Latest version: 0.1.5

# env

This module helps normalise your environment variables. It is part of the moped suite of utilities for creating composable configs for building node.js and react apps.

You must load env before all other modules.

## Installation

```
yarn add --dev @moped/env
```

## Usage ES6

If you want your users to specify NODE_ENV manually:

```js
import '@moped/env/auto';
import * as webpack from 'webpack;
```

In your build file:

```js
import '@moped/env/production';
import * as webpack from 'webpack;
```

In your tests:

```js
import '@moped/env/test';
import * as webpack from 'webpack;
```

In development:

```js
import '@moped/env/development';
import * as webpack from 'webpack;
```

## Usage ES5

If you want your users to specify NODE_ENV manually:

```js
require('@moped/env/auto');
const webpack = require('webpack');
```

In your build file:

```js
require('@moped/env/production');
const webpack = require('webpack');
```

In your tests:

```js
require('@moped/env/test');
const webpack = require('webpack');
```

In development:

```js
require('@moped/env/development');
const webpack = require('webpack');
```

## Configuration

Once you are using `@moped/env`, you can configure your environment using `.env` files. You should make sure the following is included in your `.gitignore` file:

```
.env.local
.env.development.local
.env.test.local
.env.production.local
```

When reading an environment variable, `@moped/env` will first look in the actual environment, then `.env.{NODE_ENV}.local`, then `.env.{NODE_ENV}`, then `.env.local` then `.env`. You use `.env` for config shared amongst all environments/for setting up a default config. You can use the `.local` variants for confidential configuration that you don't want published to GitHub, and you can use the `{NODE_ENV}` variants to override config in different environments.

You should always try to ensure your app at least runs with no `.local` config, as this will make it easier to onboard new team members.

## LICENSE

MIT
npm package: @moped/loader-perf-log
Description: This file loggs the time taken by loaders for each file. It is part of the moped suite of utilities for creating composable configs for building node.js and react apps.
Latest version: 0.0.6

# loader-perf-log

This file loggs the time taken by loaders for each file. It is part of the moped suite of utilities for creating composable configs for building node.js and react apps.

Loaders can be where a lot of the build time is taken in webpack.  Logging this duration helps you tell what the best things to optimise are

## Installation

```
yarn add --dev @moped/loader-perf-log
```

## Usage

```js
module.exports = {
  entry: __dirname + '/src/index.js',
  output: {
    path: __dirname + '/build',
    filename: 'static/js/[name].[chunkhash:8].js',
    publicPath: '/',
  },
  resolve: {
    extensions: ['.js', '.json'],
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        include: __dirname + '/src',
        use: [
          {
            loader: '@moped/loader-perf-log',
            options: 'babel',
          },
          {
            loader: 'babel-loader',
          },
        ],
      },
    ],
  },
};

```

## Licence

MIT
npm package: @moped/node-builtins
Description: An array of the core node.js modules. It is part of the moped suite of utilities for creating composable configs for building node.js and react apps.
Latest version: 0.0.7

# node-builtins

An array of the core node.js modules. It is part of the moped suite of utilities for creating composable configs for building node.js and react apps.

This module is useful for building node.js apps using webpack.

## Installation

```
yarn add @moped/node-builtins
```

## Usage

```js
import builtins from '@moped/node-builtins';

function isBuiltin(name) {
  return builtins.indexOf(name) !== -1;
}
```

## License

MIT
npm package: @moped/plugin-noop
Description: This module provides an empty webpack plugin that doesn't do anything. It is part of the moped suite of utilities for creating composable configs for building node.js and react apps.
Latest version: 0.0.7

# plugin-noop

This module provides an empty webpack plugin that doesn't do anything. It is part of the moped suite of utilities for creating composable configs for building node.js and react apps.

This is useful if you need to enable/disable a plugin for different environments. We return this instead of ExtractTextPlugin in `@moped/rule-css` in development.

## Installation

```
yarn add --dev @moped/plugin-noop
```

## Usage

```js
const NoOpPlugin = require('@moped/plugin-noop');

module.exports = {
  entry: __dirname + '/src/index.js',
  output: {
    path: __dirname + '/build',
    filename: 'index.js',
    publicPath: '/',
  },
  plugins: [
    process.env.NODE_ENV === 'development'
      ? new NoOpPlugin()
      : new SomeOtherPlugin(),
  ],
};
```

## Licence

MIT
npm package: @moped/react-broadcast
Description: An implementation of the new react context API: https://github.com/reactjs/rfcs/pull/2
Latest version: 1.0.5
Deprecated: Use React's built in context API

# react-broadcast

An implementation of the new react context API: https://github.com/reactjs/rfcs/pull/2

## Installation

```
yarn add @moped/react-broadcast
```

## Usage

```ts
import createBroadcast from '@moped/react-broadcast';

const {Broadcast, Subscriber} = createBroadcast('black');

const ColoredLink = ({href, children}) => (
  <Subscriber
    children={color => (
      <a href={href} style={{color}}>
        {children}
      </a>
    )}
  />
);

<div>
  <Broadcast value="green">
    <ColoredLink href="/">Link A</ColoredLink>
    <ColoredLink href="/">Link B</ColoredLink>
    <ColoredLink href="/">Link C</ColoredLink>
  </Broadcast>
  <Broadcast value="red">
    <ColoredLink href="/">Link D</ColoredLink>
    <ColoredLink href="/">Link E</ColoredLink>
    <ColoredLink href="/">Link F</ColoredLink>
  </Broadcast>
  <ColoredLink href="/">Link G</ColoredLink>
  <ColoredLink href="/">Link H</ColoredLink>
  <ColoredLink href="/">Link I</ColoredLink>
</div>;
```

Links A, B and C will be green. Links D, E and F will be red. Since they are not inside a Broadcast, Links G H and I will take the default color of black.

## License

MIT
npm package: @moped/react-modal
Description: This is a react-modal component with no default styling. It takes care of the tricky problem of keeping your content around while you animate the hiding of the modal.
Latest version: 0.1.3

# react-modal

This is a react-modal component with no default styling. It takes care of the tricky problem of keeping your content around while you animate the hiding of the modal.

## Installation

```
yarn add @moped/react-modal
```

## Usage

```typescript
import * as React from 'react';
import ModalDialog, {
  Dialog,
  ModalRenderProps,
  ModalProvider,
} from '@moped/react-modal';

function ModalDialogView(props: ModalRenderProps) {
  return (
    <div
      style={{
        opacity: props.open ? 1 : 0,
        visibility: props.open || props.animating ? 'visible' : 'hidden',
        overflowX: 'hidden',
        overflowY: 'auto',
        position: 'fixed',
        top: 0,
        right: 0,
        bottom: 0,
        left: 0,
        zIndex: 1050,
        background: 'hsla(0, 0%, 0%, 0.5)',
        transition: 'opacity 0.15s linear',
        display: 'flex',
        justifyContent: 'center',
        alignItems: 'center',
      }}
      onClick={props.onClose}
    >
      <Dialog
        open={props.open}
        style={{
          transform: props.open ? 'translate(0,0)' : 'translate(0,-100vh)',
          display: 'block',
          position: 'relative',
          flexShrink: 0,
          margin: '1em 25vw',
          color: 'inherit',
          border: '1px solid black',
          borderRadius: '0.25em',
          padding: '1em',
          background: 'white',

          height: 'auto',
          width: 'auto',
          transition: 'transform 0.3s ease-out',
        }}
        onClick={e => e.stopPropagation()}
      >
        {props.children}
      </Dialog>
    </div>
  );
}

class RestOfApplication extends React.Component {
  state = {open: false};
  _openModal = () => this.setState({open: true});
  _closeModal = () => this.setState({open: false});
  _renderModal = () => {
    // ideally here you would render the modal's title, close button etc.
    return <div>Hello World</div>;
  };
  render() {
    return (
      <React.Fragment>
        <Button onClick={this._openModal}>Open</Button>
        {this.state.open ? (
          <ModalDialog onClose={this._closeModal}>
            {this._renderModal}
          </ModalDialog>
        ) : null}
      </React.Fragment>
    );
  }
}
function App() {
  return (
    <ModalProvider animationDuration={300} renderModal={ModalDialogView}>
      <RestOfApplication />
    </ModalProvider>
  );
}
```

## License

MIT
npm package: @moped/register-service-worker
Description: A helper for managing the lifecycle of a service worker. It is part of the moped suite of utilities for creating composable configs for building node.js and react apps.
Latest version: 0.0.8

# register-service-worker

A helper for managing the lifecycle of a service worker. It is part of the moped suite of utilities for creating composable configs for building node.js and react apps.

## Installation

```
yarn add @moped/register-service-worker
```

## Usage

```js
import register, {unregister} from '@moped/register-service-worker';

register({
  serviceWorkerNotInstalling() {
    console.log('Service worker not installing.');
  },
  newContentAvailable() {
    // At this point, the old content will have been purged and
    // the fresh content will have been added to the cache.
    // It's the perfect time to display a "New content is
    // available; please refresh." message in your web app.
    console.log('New content is available; please refresh.');
  },
  contentCached() {
    // At this point, everything has been precached.
    // It's the perfect time to display a
    // "Content is cached for offline use." message.
    console.log('Content is cached for offline use.');
  },
  noInternetConnectionFound() {
    // Only called in development mode, when the backend is
    // not currently running.
    console.log(
      'No internet connection found. App is running in offline mode.',
    );
  },
  errorRegisteringServiceWorker(err: Error){
    console.error('Error during service worker registration:', error);
  },
});
```

## License

MIT
npm package: @moped/rule-css
Description: This module provides a sensible rule for handling css in webpack applications. It is part of the moped suite of utilities for creating composable configs for building node.js and react apps.
Latest version: 0.0.14

# rule-css

This module provides a sensible rule for handling css in webpack applications. It is part of the moped suite of utilities for creating composable configs for building node.js and react apps.

In development, css is included inline in the JavaScript bundle. In production, the css is extracted into a separate file.  For this reason, the return value consists of a `rule` and a `plugin`.

## Installation

```
yarn add --dev @moped/rule-css
```

## Usage

```js
const createCssRule = require('@moped/rule-css');

const css = createCssRule({
  environment: process.env.NODE_ENV,
  cssFileName: 'index.css',
  shouldUseRelativeAssetPaths: false,
  disableSourceMaps: false,
});

module.exports = {
  entry: __dirname + '/src/index.js',
  output: {
    path: __dirname + '/build',
    filename: 'index.js',
    publicPath: '/',
  },
  module: {
    rules: [css.rule],
  },
  plugins: [css.plugin],
};
```

### Options

#### Options.environment

This can be `'development'`, `'production'` or `'test'`. If you don't provide it, it will default to the value of NODE_ENV.  If neither are specified, an exception will be thrown. It will also throw an exception if any value other than `'development'`, `'production'` and `'test'` is used.

#### Options.platform

This can be `'server'` or `'client'`. If you don't provide it, it will default to `'client'`.  Set this to `'server'` to build a server side version of your app that just excludes the css files.  If you are using `:local(.classNames)`, these should still work, providing your webpack config is otherwise the same between client and server.

#### Options.cssFileName

This is the name of the generated css file, relative to the build folder. It defaults to `'static/css/[name].[contenthash:8].css'`. The `[name]` and `[contenthash:8]` tokens will be replaced with appropriate values.

#### Options.shouldUseRelativeAssetPaths

If you're not yet sure what the public path of your app will be. i.e. you don't know if it will be at `https://example.com/` or `https://example.com/foo/bar`, you can use relative paths to ensure that the app always works.  N.B. this will break if you are using client side routing using push state (e.g. react-router).  You should only enable this if you're sure you need it.

#### Options.disableSourceMaps

If you are building a very large application, generating source maps may become too slow, and might not be worth it. You can use this option to disable source maps. You can alternatively set the `GENERATE_SOURCEMAP` environment variable to `false` (this option is for compatibility with create-react-app).

## Licence

MIT
npm package: @moped/rule-file
Description: This module provides a sensible rule for handling arbitrary files in webpack apps. It is part of the moped suite of utilities for creating composable configs for building node.js and react apps.
Latest version: 0.0.9

# rule-css

This module provides a sensible rule for handling arbitrary files in webpack apps. It is part of the moped suite of utilities for creating composable configs for building node.js and react apps.

When you import a file using this package, you get the url of that file.

## Installation

```
yarn add --dev @moped/rule-file
```

## Usage

```js
const createFileRule = require('@moped/rule-file');

module.exports = {
  entry: __dirname + '/src/index.js',
  output: {
    path: __dirname + '/build',
    filename: 'index.js',
    publicPath: '/',
  },
  module: {
    rules: [createFileRule()],
  },
};
```

## Licence

MIT
npm package: @moped/sql
Description: This module provides a method for writing sql queries that is as safe as it possibly can be from SQL injection. It is part of the moped suite of utilities for creating composable configs for building node.js and react apps.
Latest version: 0.0.7

# sql

This module provides a method for writing sql queries that is as safe as it possibly can be from SQL injection. It is part of the moped suite of utilities for creating composable configs for building node.js and react apps.

This module is designed to be used in conjunction with `@moped/db-pg`, but I intend to make it portable to any other SQL databases supported by moped.

## Installation

```
yarn add @moped/sql
```

## Usage

```js
import { sql } from 'pg-sql'
 
const tableName = 'user'
const id = 10
const query = sql`select * from ${sql.ident(tableName)} where id = ${id}`
```

### ``sql`...` ``

A template string tag which interpolates all values as placeholders unless they are escaped with a function from this package such as `sql.ident` or `sql.__dangerous__rawValue`.

Example:

```js
sql`select * from user where id = ${id}`
```

### `sql.ident(...names)`

Creates a Postgres identifier. A qualified identifier will be created if more than one name is passed. If a non-string value is used for a name, such as a symbol, a local identifier will be generated.

Examples:

```js
sql`select * from ${sql.ident('user')}`
// -> 'select * from "user"'

sql`select * from ${sql.ident('schema', 'user')}`
// -> 'select * from "schema"."user"'

const fromIdent = Symbol()

sql`select * from user as ${sql.ident(fromIdent)}`
// -> 'select * from user as __local_0__'
```

### `sql.__dangerous__rawValue(text)`

Use a string of text directly in the SQL. Helpful if you need to escape the constraints of this library.

> **Warning:** If you use arbitrary user generated input anywhere inside the text you pass to `sql.__dangerous__rawValue`, you will have a SQL injection vulnerability. Try not to use `sql.__dangerous__rawValue` unless absolutely necessary.

Example:

```js
sql`select * from user where id ${sql.__dangerous__rawValue('=')} 5`
// -> 'select * from user where id = 5'
```

### `sql.join(queries, seperator?)`

Joins an array of SQL queries together with an optional seperator. Works similarly to `Array#join`.

Example:

```js
sql`select ${sql.join([sql.query`id`, sql.query`name`], ', ')} from user`
// -> 'select id, name from user'
```

## Thanks

## Licence

MIT
npm package: @moped/start-server
Description: This module provides an easy way to run a webpack bundle in node.js with hot reloading. It is part of the moped suite of utilities for creating composable configs for building node.js and react apps.
Latest version: 0.0.11

# start-server

This module provides an easy way to run a webpack bundle in node.js with hot reloading. It is part of the moped suite of utilities for creating composable configs for building node.js and react apps.

This module uses a custom hot reloader to do hot-reloading of individual modules if you use `module.accept`, and fall back to restarting the entire server if there are syntax errors or runtime errors or a module was not handled by `module.accept`.

## Installation

```
yarn add --dev @moped/start-server
```

## Usage

There are two ways to use start-server.  One for HTTP servers, which renders errror pages when in the error states, and queues incoming requests during the build process.  The other for any kind of node.js app.

> **N.B.** This plugin includes the `webpack.HotModuleReplacementPlugin` plugin, so if you have that plugin already in your config, you **must** remove it.

### HTTP Servers

#### webpack.config.js

```js
const StartServerPlugin = require('@moped/start-server');

module.exports = {
  entry: __dirname + '/src/index.js',
  output: {
    path: __dirname + '/build',
    filename: 'server.js',
  },
  plugins: [
    new StartServerPlugin({env: {PORT: 3000}}),
  ]
};
```

#### index.js

This file just handles hot reloading and actually listening on a port. This lets webpack replace individual modules for most reloads, rather than rebooting the entire node process.

```js
if (process.env.NODE_ENV === 'production') {
  require('./server').listen(process.env.PORT);
} else {
  const setServer = require('@moped/start-server/dev-server');
  setServer(require('./server'));

  module.hot.accept('./server', () => {
    setServer(require('./server'));
  });
}
```

#### server.js

This is your actual server.  Can be an express server, or anything that exports a function that takes `req` and `res` as the two arguents.

```js
const express = require('express');
const app = express();

app.get('/', (req, res) => {
  res.send('Hello World');
});

module.exports = app;
```

### Custom Node Apps

This setup automatically shuts down the node process for any compiler errors or uncaught runtime errors, restarting it on the first successful build.  It will do hot module replacement wherever possible, and fall back to restarting the entire node process if hot module replacement fails.

```js
const StartServerPlugin = require('@moped/start-server');

module.exports = {
  entry: [
    // this additional entry restarts the node process for updates
    StartServerPlugin.hotEntry,
    __dirname + '/src/index.js'
  ],
  output: {
    path: __dirname + '/build',
    filename: 'server.js',
  },
  plugins: [
    new StartServerPlugin(/* {...options} */),
  ]
};
```

## Licence

MIT
npm package: @mopeys/enum-hub
Description: ## Install
Author: mike.zhu
Latest version: 0.0.7

# enum-hub

## Install

```
$ npm install @mopeys/enum-hub
```

## Usage

```js
const eh = new EnumHub({
  fetchRemote: async (name) => {
    return await fetch(`/api/enum/${name}`);
  },
});

async function main() {
  await eh.getEnum("MEDICAL_TYPE"); // first time, from remote
  await eh.getEnum("MEDICAL_TYPE"); // from local
}

main();
```