Add this as a dependency to your project using npm with
$ npm install @meltwater/phi
or using Yarn with
$ yarn add @meltwater/phi
//=> 'bar'//=> false//=> ['foo', 'foo', 'foo', 'foo', 'foo']
$ git clone https://github.com/meltwater/phi.git $ cd phi $ nvm install $ yarn
Run each command below in a separate terminal window:
$ yarn run watch $ yarn run test:watch
Development and Testing
The phi source is hosted on GitHub. Clone the project with
$ git clone firstname.lastname@example.org:meltwater/phi.git
Be sure that all commands run under the correct Node version, e.g., if using nvm, install the correct version with
$ nvm install
Set the active version for each shell session with
$ nvm use
Install the development dependencies with
CircleCI should already be configured: this section is for reference only.
The following environment variables must be set on CircleCI:
NPM_TOKEN: npm token for installing and publishing packages.
NPM_TEAM: npm team to grant read-only package access (format
CODECOV_TOKEN: Codecov token for uploading coverage reports (optional).
These may be set manually or by running the script
For documentation publishing, CircleCI must have an SSH key for
added as a deploy key
with write access on the GitHub repository.
Primary development tasks are defined under
and available via
View them with
$ yarn run
Lint, test, and transpile the production build to
$ yarn run dist
Publishing a new release
Release a new version using
This will run all tests, update the version number,
create and push a tagged commit,
and trigger CircleCI to publish the new version to npm.
- Update the CHANGELOG before each new release after version 1.
- New versions are released when the commit message is a valid version number.
- Versions are only published on release branches:
masterbranch or any branch matching
- If branch protection options are enabled,
you must first run
npm versionon a separate branch, wait for the commit to pass any required checks, then merge and push the changes to a release branch.
- Do not use the GitHub pull request button to merge version commits as the commit tagged with the new version number will not match after merging.
See the full documentation on using examples.
View all examples with
$ yarn run example
View available commands with
$ yarn run gulp --tasks
Run all linters with
$ yarn run lint
$ yarn run watch
$ yarn run format
- Test files end in
- Unit tests are placed under
libalongside the tested module.
- Integration tests are placed in
- Static files used in tests are placed in
Watch and run tests on changes with
$ yarn run test:watch
If using AVA snapshot testing, update snapshots with
$ yarn run test:update
Generate a coverage report with
$ yarn run report
An HTML version will be saved in
Create a breakpoint by adding the statement
debugger to the test
and start a debug session with, e.g.,
$ yarn run test:inspect lib/entries.spec.js
Watch and restart the debugging session on changes with
$ yarn run test:inspect:watch lib/entries.spec.js
The author and active contributors may be found in
$ jq .author < package.json $ jq .contributors < package.json
To submit a patch:
- Request repository access by submitting a new issue.
- Create your feature branch (
git checkout -b my-new-feature).
- Make changes and write tests.
- Commit your changes (
git commit -am 'Add some feature').
- Push to the branch (
git push origin my-new-feature).
- Create a new Pull Request.
The source code for this npm package is licensed under the Apache License, Version 2.0 (the "License"); you may not use this source code except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
This software is provided by the copyright holders and contributors "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright holder or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.