Skip to content

Commit 833cca0

Browse files
Documentation Updates (#18)
* Updated prototype.count.md, es6 and codepen. * Updated prototype.difference.md codepen * Updated documentation for filter-members-and-get-count.md * updated doc/prototype/filter-members.md to use codepen. * updated doc/prototype/identity-keys.md to use codepen, updated to use ES6 syntax, and proper indentation under the signature. * Updated to use codepen added example if no query. - Both examples use codepen - Updated to show if first parameter (query) is an empty object. * Updated doc/prototype/intersection.md to include codepen and proper indentation * updated doc/prototype/is-defined-and-has-members.md to use codepen and ES6 syntax, and be properly indented. * Updated doc/prototype/is-equal.md to be codepenable and indented properly. * doc/prototype/is-member.md now uses codepen. Fixed indentation. * doc/prototype/is-proper-subset.md uses codepen and is properly indented. * Updated doc/prototype/is-special.md - Uses codepen - has proper indentation - uses es6 syntax - example was changed to use `.isSpecial` method from `.isDefinedAndHasMembers`. - changed documentation under signature text and return text to reflect that the object returns true if it is `UNIVERSAL`, `EMPTY`, `UNDEFINABLE`, or `UNKNOWABLE`. * Updated /doc/prototype/is-defined-and-has-members `.isDefinedAndHasMembers` returns the query object unless the query object is `EMPTY`, `UNDEFINABLE`, or `UNKNOWABLE`. - updated documentation to reflect how `.isDefinedAndHasMembers` works. - updated example to reflect how method works. * doc/prototype/is-subset.md is now codepenable fixed indentation. * doc/prototype/member-identity.md is now codepenable using ES6 syntax and has proper indentation. * doc/prototype/union-members.md is now codepenable and has proper indentation. * doc/prototype/union.md codepen examples - proper indentation - example now links to codepen - using `JSON.stringify` to properly show nesting in codepen log - added note about using `JSON.stringify` * fixed spelling error -> . * updated doc/status/AndKeys.md to use codepen/es6 syntax. Linked references to can-query-logic.set static-methods. * doc/static/undefinable.md updated examples - Examples are now using ES6 syntax. - Examples link to codepen. - Example referencing `.Not` operator doesn't link to codepen as no such operator exists. - Removed fragment "Use UNKNOWABLE to represent". * updated examples in docs/static/unknowable.md to use codepen. * doc/static/makeEnum.md updated to es6 and codepen - Successfully working QueryLogic.makeEnum signature example. - Still needs Alternative example working. * added commented out codepen tag * updated doc/static-methods to use codepen and es6 syntax * updated doc/etc.md to link to codepen and use es6 syntax * mostly working example for doc/static/makeEnum.md Alternatives heading. * latest updates, mostly include example reworks. * Continue to update examples. Many of these examples have been updated. I am still waiting for completion on a few errors. * updated examples. * fixed spacing in examples. * can-query-logic.prototype.index updates - Added @description - fixed indentation - fixed first example * updated can-query-logic.prototype.is-member to reference instead of Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.wvNIyG0otk/Render BASH=/bin/bash BASH_ARGC=() BASH_ARGV=() BASH_LINENO=() BASH_REMATCH=([0]="c") BASH_SOURCE=() BASH_VERSINFO=([0]="3" [1]="2" [2]="57" [3]="1" [4]="release" [5]="x86_64-apple-darwin17") BASH_VERSION='3.2.57(1)-release' COLUMNS=80 DIRSTACK=() EUID=501 GROUPS=() HISTFILE=/Users/thomasdillard/.bash_sessions/B034DD81-E19A-4CD2-9C21-54E50FE50DC2.historynew HISTFILESIZE=500 HISTSIZE=500 HOME=/Users/thomasdillard HOSTNAME=Thomass-MacBook-Pro-2.local HOSTTYPE=x86_64 IFS=$' \t\n' LANG=en_US.UTF-8 LINES=21 LOGNAME=thomasdillard MACHTYPE=x86_64-apple-darwin17 MAILCHECK=60 NVM_BIN=/Users/thomasdillard/.nvm/versions/node/v10.9.0/bin NVM_CD_FLAGS= NVM_DIR=/Users/thomasdillard/.nvm OLDPWD=/Users/thomasdillard/Documents/bitovi OPTERR=1 OPTIND=1 OSTYPE=darwin17 PATH=/Users/thomasdillard/.nvm/versions/node/v10.9.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin PIPESTATUS=([0]="0") PPID=9830 PROMPT_COMMAND=update_terminal_cwd PS1='\h:\W \u\$ ' PS2='> ' PS4='+ ' PWD=/Users/thomasdillard/Documents/bitovi/can-query-logic SHELL=/bin/bash SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor SHELL_SESSION_DID_HISTORY_CHECK=1 SHELL_SESSION_DID_INIT=1 SHELL_SESSION_DIR=/Users/thomasdillard/.bash_sessions SHELL_SESSION_FILE=/Users/thomasdillard/.bash_sessions/B034DD81-E19A-4CD2-9C21-54E50FE50DC2.session SHELL_SESSION_HISTFILE=/Users/thomasdillard/.bash_sessions/B034DD81-E19A-4CD2-9C21-54E50FE50DC2.history SHELL_SESSION_HISTFILE_NEW=/Users/thomasdillard/.bash_sessions/B034DD81-E19A-4CD2-9C21-54E50FE50DC2.historynew SHELL_SESSION_HISTFILE_SHARED=/Users/thomasdillard/.bash_history SHELL_SESSION_HISTORY=1 SHELL_SESSION_TIMESTAMP_FILE=/Users/thomasdillard/.bash_sessions/_expiration_check_timestamp SHLVL=1 SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.r2CiSbr7dz/Listeners TERM=xterm-256color TERM_PROGRAM=Apple_Terminal TERM_PROGRAM_VERSION=404 TERM_SESSION_ID=B034DD81-E19A-4CD2-9C21-54E50FE50DC2 TMPDIR=/var/folders/j2/6lrfz1t94mdgmdn427khwnpr0000gn/T/ UID=501 USER=thomasdillard XPC_FLAGS=0x0 XPC_SERVICE_NAME=0 _=--a iojs_version_has_solaris_binary () { local IOJS_VERSION; IOJS_VERSION="$1"; local STRIPPED_IOJS_VERSION; STRIPPED_IOJS_VERSION="$(nvm_strip_iojs_prefix "$IOJS_VERSION")"; if [ "_$STRIPPED_IOJS_VERSION" = "$IOJS_VERSION" ]; then return 1; fi; nvm_version_greater_than_or_equal_to "$STRIPPED_IOJS_VERSION" v3.3.1 } node_version_has_solaris_binary () { local NODE_VERSION; NODE_VERSION="$1"; local STRIPPED_IOJS_VERSION; STRIPPED_IOJS_VERSION="$(nvm_strip_iojs_prefix "$NODE_VERSION")"; if [ "_$STRIPPED_IOJS_VERSION" != "_$NODE_VERSION" ]; then return 1; fi; nvm_version_greater_than_or_equal_to "$NODE_VERSION" v0.8.6 && ! nvm_version_greater_than_or_equal_to "$NODE_VERSION" v1.0.0 } nvm () { if [ $# -lt 1 ]; then nvm --help; return; fi; local DEFAULT_IFS; DEFAULT_IFS=" $(nvm_echo t | command tr t \\t) "; if [ "${IFS}" != "${DEFAULT_IFS}" ]; then IFS="${DEFAULT_IFS}" nvm "$@"; return $?; fi; local COMMAND; COMMAND="${1-}"; shift; local VERSION; local ADDITIONAL_PARAMETERS; case $COMMAND in 'help' | '--help') local NVM_IOJS_PREFIX; NVM_IOJS_PREFIX="$(nvm_iojs_prefix)"; local NVM_NODE_PREFIX; NVM_NODE_PREFIX="$(nvm_node_prefix)"; nvm_echo; nvm_echo "Node Version Manager"; nvm_echo; nvm_echo 'Note: <version> refers to any version-like string nvm understands. This includes:'; nvm_echo ' - full or partial version numbers, starting with an optional "v" (0.10, v0.1.2, v1)'; nvm_echo " - default (built-in) aliases: $NVM_NODE_PREFIX, stable, unstable, $NVM_IOJS_PREFIX, system"; nvm_echo ' - custom aliases you define with `nvm alias foo`'; nvm_echo; nvm_echo ' Any options that produce colorized output should respect the `--no-colors` option.'; nvm_echo; nvm_echo 'Usage:'; nvm_echo ' nvm --help Show this message'; nvm_echo ' nvm --version Print out the installed version of nvm'; nvm_echo ' nvm install [-s] <version> Download and install a <version>, [-s] from source. Uses .nvmrc if available'; nvm_echo ' --reinstall-packages-from=<version> When installing, reinstall packages installed in <node|iojs|node version number>'; nvm_echo ' --lts When installing, only select from LTS (long-term support) versions'; nvm_echo ' --lts=<LTS name> When installing, only select from versions for a specific LTS line'; nvm_echo ' --skip-default-packages When installing, skip the default-packages file if it exists'; nvm_echo ' --latest-npm After installing, attempt to upgrade to the latest working npm on the given node version'; nvm_echo ' nvm uninstall <version> Uninstall a version'; nvm_echo ' nvm uninstall --lts Uninstall using automatic LTS (long-term support) alias `lts/*`, if available.'; nvm_echo ' nvm uninstall --lts=<LTS name> Uninstall using automatic alias for provided LTS line, if available.'; nvm_echo ' nvm use [--silent] <version> Modify PATH to use <version>. Uses .nvmrc if available'; nvm_echo ' --lts Uses automatic LTS (long-term support) alias `lts/*`, if available.'; nvm_echo ' --lts=<LTS name> Uses automatic alias for provided LTS line, if available.'; nvm_echo ' nvm exec [--silent] <version> [<command>] Run <command> on <version>. Uses .nvmrc if available'; nvm_echo ' --lts Uses automatic LTS (long-term support) alias `lts/*`, if available.'; nvm_echo ' --lts=<LTS name> Uses automatic alias for provided LTS line, if available.'; nvm_echo ' nvm run [--silent] <version> [<args>] Run `node` on <version> with <args> as arguments. Uses .nvmrc if available'; nvm_echo ' --lts Uses automatic LTS (long-term support) alias `lts/*`, if available.'; nvm_echo ' --lts=<LTS name> Uses automatic alias for provided LTS line, if available.'; nvm_echo ' nvm current Display currently activated version'; nvm_echo ' nvm ls List installed versions'; nvm_echo ' nvm ls <version> List versions matching a given <version>'; nvm_echo ' nvm ls-remote List remote versions available for install'; nvm_echo ' --lts When listing, only show LTS (long-term support) versions'; nvm_echo ' nvm ls-remote <version> List remote versions available for install, matching a given <version>'; nvm_echo ' --lts When listing, only show LTS (long-term support) versions'; nvm_echo ' --lts=<LTS name> When listing, only show versions for a specific LTS line'; nvm_echo ' nvm version <version> Resolve the given description to a single local version'; nvm_echo ' nvm version-remote <version> Resolve the given description to a single remote version'; nvm_echo ' --lts When listing, only select from LTS (long-term support) versions'; nvm_echo ' --lts=<LTS name> When listing, only select from versions for a specific LTS line'; nvm_echo ' nvm deactivate Undo effects of `nvm` on current shell'; nvm_echo ' nvm alias [<pattern>] Show all aliases beginning with <pattern>'; nvm_echo ' nvm alias <name> <version> Set an alias named <name> pointing to <version>'; nvm_echo ' nvm unalias <name> Deletes the alias named <name>'; nvm_echo ' nvm install-latest-npm Attempt to upgrade to the latest working `npm` on the current node version'; nvm_echo ' nvm reinstall-packages <version> Reinstall global `npm` packages contained in <version> to current version'; nvm_echo ' nvm unload Unload `nvm` from shell'; nvm_echo ' nvm which [current | <version>] Display path to installed node version. Uses .nvmrc if available'; nvm_echo ' nvm cache dir Display path to the cache directory for nvm'; nvm_echo ' nvm cache clear Empty cache directory for nvm'; nvm_echo; nvm_echo 'Example:'; nvm_echo ' nvm install 8.0.0 Install a specific version number'; nvm_echo ' nvm use 8.0 Use the latest available 8.0.x release'; nvm_echo ' nvm run 6.10.3 app.js Run app.js using node 6.10.3'; nvm_echo ' nvm exec 4.8.3 node app.js Run `node app.js` with the PATH pointing to node 4.8.3'; nvm_echo ' nvm alias default 8.1.0 Set default node version on a shell'; nvm_echo ' nvm alias default node Always default to the latest available node version on a shell'; nvm_echo; nvm_echo 'Note:'; nvm_echo ' to remove, delete, or uninstall nvm - just remove the `$NVM_DIR` folder (usually `~/.nvm`)'; nvm_echo ;; "cache") case "${1-}" in dir) nvm_cache_dir ;; clear) local DIR; DIR="$(nvm_cache_dir)"; if command rm -rf "${DIR}" && command mkdir -p "${DIR}"; then nvm_echo 'nvm cache cleared.'; else nvm_err "Unable to clear nvm cache: ${DIR}"; return 1; fi ;; *) nvm --help 1>&2; return 127 ;; esac ;; "debug") local ZSH_HAS_SHWORDSPLIT_UNSET; local OS_VERSION; ZSH_HAS_SHWORDSPLIT_UNSET=1; if nvm_has "setopt"; then ZSH_HAS_SHWORDSPLIT_UNSET="$(set +e ; setopt | nvm_grep -q shwordsplit ; nvm_echo $?)"; setopt shwordsplit; fi; nvm_err "nvm --version: v$(nvm --version)"; if [ -n "${TERM_PROGRAM-}" ]; then nvm_err "\$TERM_PROGRAM: $TERM_PROGRAM"; fi; nvm_err "\$SHELL: $SHELL"; nvm_err "\$SHLVL: ${SHLVL-}"; nvm_err "\$HOME: $HOME"; nvm_err "\$NVM_DIR: '$(nvm_sanitize_path "$NVM_DIR")'"; nvm_err "\$PATH: $(nvm_sanitize_path "$PATH")"; nvm_err "\$PREFIX: '$(nvm_sanitize_path "$PREFIX")'"; nvm_err "\$NPM_CONFIG_PREFIX: '$(nvm_sanitize_path "$NPM_CONFIG_PREFIX")'"; nvm_err "\$NVM_NODEJS_ORG_MIRROR: '${NVM_NODEJS_ORG_MIRROR}'"; nvm_err "\$NVM_IOJS_ORG_MIRROR: '${NVM_IOJS_ORG_MIRROR}'"; nvm_err "shell version: '$(${SHELL} --version | command head -n 1)'"; nvm_err "uname -a: '$(command uname -a | command awk '{$2=""; print}' | command xargs)'"; if [ "$(nvm_get_os)" = "darwin" ] && nvm_has sw_vers; then OS_VERSION="$(sw_vers | command awk '{print $2}' | command xargs)"; else if [ -r "/etc/issue" ]; then OS_VERSION="$(command head -n 1 /etc/issue | command sed 's/\\.//g')"; if [ -z "${OS_VERSION}" ] && [ -r "/etc/os-release" ]; then OS_VERSION="$(. /etc/os-release && echo "${NAME}" "${VERSION}")"; fi; fi; fi; if [ -n "${OS_VERSION}" ]; then nvm_err "OS version: ${OS_VERSION}"; fi; if nvm_has "curl"; then nvm_err "curl: $(nvm_command_info curl), $(command curl -V | command head -n 1)"; else nvm_err "curl: not found"; fi; if nvm_has "wget"; then nvm_err "wget: $(nvm_command_info wget), $(command wget -V | command head -n 1)"; else nvm_err "wget: not found"; fi; for tool in git grep awk sed cut basename rm mkdir xargs; do if nvm_has "${tool}"; then nvm_err "${tool}: $(nvm_command_info ${tool}), $(command ${tool} --version | command head -n 1)"; else nvm_err "${tool}: not found"; fi; done; local NVM_DEBUG_OUTPUT; for NVM_DEBUG_COMMAND in 'nvm current' 'which node' 'which iojs' 'which npm' 'npm config get prefix' 'npm root -g'; do NVM_DEBUG_OUTPUT="$($NVM_DEBUG_COMMAND 2>&1)"; nvm_err "$NVM_DEBUG_COMMAND: $(nvm_sanitize_path "$NVM_DEBUG_OUTPUT")"; done; if [ "$ZSH_HAS_SHWORDSPLIT_UNSET" -eq 1 ] && nvm_has "unsetopt"; then unsetopt shwordsplit; fi; return 42 ;; "install" | "i") local version_not_provided; version_not_provided=0; local NVM_OS; NVM_OS="$(nvm_get_os)"; if ! nvm_has "curl" && ! nvm_has "wget"; then nvm_err 'nvm needs curl or wget to proceed.'; return 1; fi; if [ $# -lt 1 ]; then version_not_provided=1; fi; local nobinary; nobinary=0; local LTS; local NVM_UPGRADE_NPM; NVM_UPGRADE_NPM=0; while [ $# -ne 0 ]; do case "$1" in -s) shift; nobinary=1 ;; -j) shift; nvm_get_make_jobs "$1"; shift ;; --lts) LTS='*'; shift ;; --lts=*) LTS="${1##--lts=}"; shift ;; --latest-npm) NVM_UPGRADE_NPM=1; shift ;; *) break ;; esac; done; local provided_version; provided_version="${1-}"; if [ -z "$provided_version" ]; then if [ "_${LTS-}" = '_*' ]; then nvm_echo 'Installing latest LTS version.'; if [ $# -gt 0 ]; then shift; fi; else if [ "_${LTS-}" != '_' ]; then nvm_echo "Installing with latest version of LTS line: $LTS"; if [ $# -gt 0 ]; then shift; fi; else nvm_rc_version; if [ $version_not_provided -eq 1 ] && [ -z "$NVM_RC_VERSION" ]; then unset NVM_RC_VERSION; nvm --help 1>&2; return 127; fi; provided_version="$NVM_RC_VERSION"; unset NVM_RC_VERSION; fi; fi; else if [ $# -gt 0 ]; then shift; fi; fi; case "${provided_version}" in 'lts/*') LTS='*'; provided_version='' ;; lts/*) LTS="${provided_version##lts/}"; provided_version='' ;; esac; VERSION="$(NVM_VERSION_ONLY=true NVM_LTS="${LTS-}" nvm_remote_version "${provided_version}")"; if [ "${VERSION}" = 'N/A' ]; then local LTS_MSG; local REMOTE_CMD; if [ "${LTS-}" = '*' ]; then LTS_MSG='(with LTS filter) '; REMOTE_CMD='nvm ls-remote --lts'; else if [ -n "${LTS-}" ]; then LTS_MSG="(with LTS filter '$LTS') "; REMOTE_CMD="nvm ls-remote --lts=${LTS}"; else REMOTE_CMD='nvm ls-remote'; fi; fi; nvm_err "Version '$provided_version' ${LTS_MSG-}not found - try \`${REMOTE_CMD}\` to browse available versions."; return 3; fi; ADDITIONAL_PARAMETERS=''; local PROVIDED_REINSTALL_PACKAGES_FROM; local REINSTALL_PACKAGES_FROM; local SKIP_DEFAULT_PACKAGES; local DEFAULT_PACKAGES; while [ $# -ne 0 ]; do case "$1" in --reinstall-packages-from=*) PROVIDED_REINSTALL_PACKAGES_FROM="$(nvm_echo "$1" | command cut -c 27-)"; if [ -z "${PROVIDED_REINSTALL_PACKAGES_FROM}" ]; then nvm_err 'If --reinstall-packages-from is provided, it must point to an installed version of node.'; return 6; fi; REINSTALL_PACKAGES_FROM="$(nvm_version "$PROVIDED_REINSTALL_PACKAGES_FROM")" || : ;; --reinstall-packages-from) nvm_err 'If --reinstall-packages-from is provided, it must point to an installed version of node using `=`.'; return 6 ;; --copy-packages-from=*) PROVIDED_REINSTALL_PACKAGES_FROM="$(nvm_echo "$1" | command cut -c 22-)"; REINSTALL_PACKAGES_FROM="$(nvm_version "$PROVIDED_REINSTALL_PACKAGES_FROM")" || : ;; --skip-default-packages) SKIP_DEFAULT_PACKAGES=true ;; *) ADDITIONAL_PARAMETERS="$ADDITIONAL_PARAMETERS $1" ;; esac; shift; done; if [ -z "${SKIP_DEFAULT_PACKAGES-}" ] && [ -f "${NVM_DIR}/default-packages" ]; then DEFAULT_PACKAGES=""; local line; while IFS=" " read -r line; do [ -n "${line}" ] || continue; [ "$(nvm_echo "$line" | command cut -c1)" != "#" ] || continue; case ${line} in *\ *) nvm_err "Only one package per line is allowed in the ${NVM_DIR}/default-packages file. Please remove any lines with multiple space-separated values."; return 1 ;; esac; DEFAULT_PACKAGES="${DEFAULT_PACKAGES}${line} "; done < "${NVM_DIR}/default-packages"; fi; if [ -n "${PROVIDED_REINSTALL_PACKAGES_FROM-}" ] && [ "$(nvm_ensure_version_prefix "${PROVIDED_REINSTALL_PACKAGES_FROM}")" = "${VERSION}" ]; then nvm_err "You can't reinstall global packages from the same version of node you're installing."; return 4; else if [ "${REINSTALL_PACKAGES_FROM-}" = 'N/A' ]; then nvm_err "If --reinstall-packages-from is provided, it must point to an installed version of node."; return 5; fi; fi; local FLAVOR; if nvm_is_iojs_version "$VERSION"; then FLAVOR="$(nvm_iojs_prefix)"; else FLAVOR="$(nvm_node_prefix)"; fi; if nvm_is_version_installed "$VERSION"; then nvm_err "$VERSION is already installed."; if nvm use "$VERSION"; then if [ "${NVM_UPGRADE_NPM}" = 1 ]; then nvm install-latest-npm; fi; if [ -z "${SKIP_DEFAULT_PACKAGES-}" ] && [ -n "${DEFAULT_PACKAGES-}" ]; then nvm_install_default_packages "$DEFAULT_PACKAGES"; fi; if [ -n "${REINSTALL_PACKAGES_FROM-}" ] && [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then nvm reinstall-packages "$REINSTALL_PACKAGES_FROM"; fi; fi; if [ -n "${LTS-}" ]; then LTS="$(echo "${LTS}" | tr '[:upper:]' '[:lower:]')"; nvm_ensure_default_set "lts/${LTS}"; else nvm_ensure_default_set "$provided_version"; fi; return $?; fi; local EXIT_CODE; EXIT_CODE=-1; if [ -n "${NVM_INSTALL_THIRD_PARTY_HOOK-}" ]; then nvm_err '** $NVM_INSTALL_THIRD_PARTY_HOOK env var set; dispatching to third-party installation method **'; local NVM_METHOD_PREFERENCE; NVM_METHOD_PREFERENCE='binary'; if [ $nobinary -eq 1 ]; then NVM_METHOD_PREFERENCE='source'; fi; local VERSION_PATH; VERSION_PATH="$(nvm_version_path "${VERSION}")"; "${NVM_INSTALL_THIRD_PARTY_HOOK}" "${VERSION}" "${FLAVOR}" std "${NVM_METHOD_PREFERENCE}" "${VERSION_PATH}" || { EXIT_CODE=$?; nvm_err '*** Third-party $NVM_INSTALL_THIRD_PARTY_HOOK env var failed to install! ***'; return $EXIT_CODE }; if ! nvm_is_version_installed "${VERSION}"; then nvm_err '*** Third-party $NVM_INSTALL_THIRD_PARTY_HOOK env var claimed to succeed, but failed to install! ***'; return 33; fi; EXIT_CODE=0; else if [ "_$NVM_OS" = "_freebsd" ]; then nobinary=1; nvm_err "Currently, there is no binary for FreeBSD"; else if [ "_$NVM_OS" = "_sunos" ]; then if ! nvm_has_solaris_binary "$VERSION"; then nobinary=1; nvm_err "Currently, there is no binary of version $VERSION for SunOS"; fi; fi; fi; if [ $nobinary -ne 1 ] && nvm_binary_available "$VERSION"; then nvm_install_binary "${FLAVOR}" std "${VERSION}"; EXIT_CODE=$?; fi; if [ "$EXIT_CODE" -ne 0 ]; then if [ -z "${NVM_MAKE_JOBS-}" ]; then nvm_get_make_jobs; fi; nvm_install_source "${FLAVOR}" std "${VERSION}" "${NVM_MAKE_JOBS}" "${ADDITIONAL_PARAMETERS}"; EXIT_CODE=$?; fi; fi; if [ "$EXIT_CODE" -eq 0 ] && nvm_use_if_needed "${VERSION}" && nvm_install_npm_if_needed "${VERSION}"; then if [ -n "${LTS-}" ]; then nvm_ensure_default_set "lts/${LTS}"; else nvm_ensure_default_set "$provided_version"; fi; if [ "${NVM_UPGRADE_NPM}" = 1 ]; then nvm install-latest-npm; EXIT_CODE=$?; fi; if [ -z "${SKIP_DEFAULT_PACKAGES-}" ] && [ -n "${DEFAULT_PACKAGES-}" ]; then nvm_install_default_packages "$DEFAULT_PACKAGES"; fi; if [ -n "${REINSTALL_PACKAGES_FROM-}" ] && [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then nvm reinstall-packages "$REINSTALL_PACKAGES_FROM"; EXIT_CODE=$?; fi; else EXIT_CODE=$?; fi; return $EXIT_CODE ;; "uninstall") if [ $# -ne 1 ]; then nvm --help 1>&2; return 127; fi; local PATTERN; PATTERN="${1-}"; case "${PATTERN-}" in --) ;; --lts | 'lts/*') VERSION="$(nvm_match_version "lts/*")" ;; lts/*) VERSION="$(nvm_match_version "lts/${PATTERN##lts/}")" ;; --lts=*) VERSION="$(nvm_match_version "lts/${PATTERN##--lts=}")" ;; *) VERSION="$(nvm_version "${PATTERN}")" ;; esac; if [ "_${VERSION}" = "_$(nvm_ls_current)" ]; then if nvm_is_iojs_version "${VERSION}"; then nvm_err "nvm: Cannot uninstall currently-active io.js version, ${VERSION} (inferred from ${PATTERN})."; else nvm_err "nvm: Cannot uninstall currently-active node version, ${VERSION} (inferred from ${PATTERN})."; fi; return 1; fi; if ! nvm_is_version_installed "${VERSION}"; then nvm_err "${VERSION} version is not installed..."; return; fi; local SLUG_BINARY; local SLUG_SOURCE; if nvm_is_iojs_version "${VERSION}"; then SLUG_BINARY="$(nvm_get_download_slug iojs binary std "${VERSION}")"; SLUG_SOURCE="$(nvm_get_download_slug iojs source std "${VERSION}")"; else SLUG_BINARY="$(nvm_get_download_slug node binary std "${VERSION}")"; SLUG_SOURCE="$(nvm_get_download_slug node source std "${VERSION}")"; fi; local NVM_SUCCESS_MSG; if nvm_is_iojs_version "${VERSION}"; then NVM_SUCCESS_MSG="Uninstalled io.js $(nvm_strip_iojs_prefix "${VERSION}")"; else NVM_SUCCESS_MSG="Uninstalled node ${VERSION}"; fi; local VERSION_PATH; VERSION_PATH="$(nvm_version_path "${VERSION}")"; if ! nvm_check_file_permissions "${VERSION_PATH}"; then nvm_err 'Cannot uninstall, incorrect permissions on installation folder.'; nvm_err 'This is usually caused by running `npm install -g` as root. Run the following commands as root to fix the permissions and then try again.'; nvm_err; nvm_err " chown -R $(whoami) \"$(nvm_sanitize_path "${VERSION_PATH}")\""; nvm_err " chmod -R u+w \"$(nvm_sanitize_path "${VERSION_PATH}")\""; return 1; fi; local CACHE_DIR; CACHE_DIR="$(nvm_cache_dir)"; command rm -rf "${CACHE_DIR}/bin/${SLUG_BINARY}/files" "${CACHE_DIR}/src/${SLUG_SOURCE}/files" "${VERSION_PATH}" 2> /dev/null; nvm_echo "${NVM_SUCCESS_MSG}"; for ALIAS in $(nvm_grep -l "$VERSION" "$(nvm_alias_path)/*" 2>/dev/null); do nvm unalias "$(command basename "$ALIAS")"; done ;; "deactivate") local NEWPATH; NEWPATH="$(nvm_strip_path "$PATH" "/bin")"; if [ "_$PATH" = "_$NEWPATH" ]; then nvm_err "Could not find $NVM_DIR/*/bin in \$PATH"; else export PATH="$NEWPATH"; hash -r; nvm_echo "$NVM_DIR/*/bin removed from \$PATH"; fi; if [ -n "${MANPATH-}" ]; then NEWPATH="$(nvm_strip_path "$MANPATH" "/share/man")"; if [ "_$MANPATH" = "_$NEWPATH" ]; then nvm_err "Could not find $NVM_DIR/*/share/man in \$MANPATH"; else export MANPATH="$NEWPATH"; nvm_echo "$NVM_DIR/*/share/man removed from \$MANPATH"; fi; fi; if [ -n "${NODE_PATH-}" ]; then NEWPATH="$(nvm_strip_path "$NODE_PATH" "/lib/node_modules")"; if [ "_$NODE_PATH" != "_$NEWPATH" ]; then export NODE_PATH="$NEWPATH"; nvm_echo "$NVM_DIR/*/lib/node_modules removed from \$NODE_PATH"; fi; fi; unset NVM_BIN ;; "use") local PROVIDED_VERSION; local NVM_USE_SILENT; NVM_USE_SILENT=0; local NVM_DELETE_PREFIX; NVM_DELETE_PREFIX=0; local NVM_LTS; while [ $# -ne 0 ]; do case "$1" in --silent) NVM_USE_SILENT=1 ;; --delete-prefix) NVM_DELETE_PREFIX=1 ;; --) ;; --lts) NVM_LTS='*' ;; --lts=*) NVM_LTS="${1##--lts=}" ;; --*) ;; *) if [ -n "${1-}" ]; then PROVIDED_VERSION="$1"; fi ;; esac; shift; done; if [ -n "${NVM_LTS-}" ]; then VERSION="$(nvm_match_version "lts/${NVM_LTS:-*}")"; else if [ -z "${PROVIDED_VERSION-}" ]; then nvm_rc_version; if [ -n "${NVM_RC_VERSION-}" ]; then PROVIDED_VERSION="$NVM_RC_VERSION"; VERSION="$(nvm_version "$PROVIDED_VERSION")"; fi; unset NVM_RC_VERSION; else VERSION="$(nvm_match_version "$PROVIDED_VERSION")"; fi; fi; if [ -z "${VERSION}" ]; then nvm --help 1>&2; return 127; fi; if [ "_$VERSION" = '_system' ]; then if nvm_has_system_node && nvm deactivate > /dev/null 2>&1; then if [ $NVM_USE_SILENT -ne 1 ]; then nvm_echo "Now using system version of node: $(node -v 2>/dev/null)$(nvm_print_npm_version)"; fi; return; else if nvm_has_system_iojs && nvm deactivate > /dev/null 2>&1; then if [ $NVM_USE_SILENT -ne 1 ]; then nvm_echo "Now using system version of io.js: $(iojs --version 2>/dev/null)$(nvm_print_npm_version)"; fi; return; else if [ $NVM_USE_SILENT -ne 1 ]; then nvm_err 'System version of node not found.'; fi; fi; fi; return 127; else if [ "_$VERSION" = "_∞" ]; then if [ $NVM_USE_SILENT -ne 1 ]; then nvm_err "The alias \"$PROVIDED_VERSION\" leads to an infinite loop. Aborting."; fi; return 8; fi; fi; if [ "${VERSION}" = 'N/A' ]; then nvm_err "N/A: version \"${PROVIDED_VERSION} -> ${VERSION}\" is not yet installed."; nvm_err ""; nvm_err "You need to run \"nvm install ${PROVIDED_VERSION}\" to install it before using it."; return 3; else if ! nvm_ensure_version_installed "${VERSION}"; then return $?; fi; fi; local NVM_VERSION_DIR; NVM_VERSION_DIR="$(nvm_version_path "$VERSION")"; PATH="$(nvm_change_path "$PATH" "/bin" "$NVM_VERSION_DIR")"; if nvm_has manpath; then if [ -z "${MANPATH-}" ]; then local MANPATH; MANPATH=$(manpath); fi; MANPATH="$(nvm_change_path "$MANPATH" "/share/man" "$NVM_VERSION_DIR")"; export MANPATH; fi; export PATH; hash -r; export NVM_BIN="$NVM_VERSION_DIR/bin"; if [ "${NVM_SYMLINK_CURRENT-}" = true ]; then command rm -f "$NVM_DIR/current" && ln -s "$NVM_VERSION_DIR" "$NVM_DIR/current"; fi; local NVM_USE_OUTPUT; NVM_USE_OUTPUT=''; if [ $NVM_USE_SILENT -ne 1 ]; then if nvm_is_iojs_version "$VERSION"; then NVM_USE_OUTPUT="Now using io.js $(nvm_strip_iojs_prefix "$VERSION")$(nvm_print_npm_version)"; else NVM_USE_OUTPUT="Now using node $VERSION$(nvm_print_npm_version)"; fi; fi; if [ "_$VERSION" != "_system" ]; then local NVM_USE_CMD; NVM_USE_CMD="nvm use --delete-prefix"; if [ -n "$PROVIDED_VERSION" ]; then NVM_USE_CMD="$NVM_USE_CMD $VERSION"; fi; if [ $NVM_USE_SILENT -eq 1 ]; then NVM_USE_CMD="$NVM_USE_CMD --silent"; fi; if ! nvm_die_on_prefix "$NVM_DELETE_PREFIX" "$NVM_USE_CMD"; then return 11; fi; fi; if [ -n "${NVM_USE_OUTPUT-}" ]; then nvm_echo "$NVM_USE_OUTPUT"; fi ;; "run") local provided_version; local has_checked_nvmrc; has_checked_nvmrc=0; local NVM_SILENT; local NVM_LTS; while [ $# -gt 0 ]; do case "$1" in --silent) NVM_SILENT='--silent'; shift ;; --lts) NVM_LTS='*'; shift ;; --lts=*) NVM_LTS="${1##--lts=}"; shift ;; *) if [ -n "$1" ]; then break; else shift; fi ;; esac; done; if [ $# -lt 1 ] && [ -z "${NVM_LTS-}" ]; then if [ -n "${NVM_SILENT-}" ]; then nvm_rc_version > /dev/null 2>&1 && has_checked_nvmrc=1; else nvm_rc_version && has_checked_nvmrc=1; fi; if [ -n "$NVM_RC_VERSION" ]; then VERSION="$(nvm_version "$NVM_RC_VERSION")" || :; fi; unset NVM_RC_VERSION; if [ "${VERSION:-N/A}" = 'N/A' ]; then nvm --help 1>&2; return 127; fi; fi; if [ -z "${NVM_LTS-}" ]; then provided_version="$1"; if [ -n "$provided_version" ]; then VERSION="$(nvm_version "$provided_version")" || :; if [ "_${VERSION:-N/A}" = '_N/A' ] && ! nvm_is_valid_version "$provided_version"; then provided_version=''; if [ $has_checked_nvmrc -ne 1 ]; then if [ -n "${NVM_SILENT-}" ]; then nvm_rc_version > /dev/null 2>&1 && has_checked_nvmrc=1; else nvm_rc_version && has_checked_nvmrc=1; fi; fi; VERSION="$(nvm_version "$NVM_RC_VERSION")" || :; unset NVM_RC_VERSION; else shift; fi; fi; fi; local NVM_IOJS; if nvm_is_iojs_version "$VERSION"; then NVM_IOJS=true; fi; local EXIT_CODE; local ZSH_HAS_SHWORDSPLIT_UNSET; ZSH_HAS_SHWORDSPLIT_UNSET=1; if nvm_has "setopt"; then ZSH_HAS_SHWORDSPLIT_UNSET="$(set +e ; setopt | nvm_grep -q shwordsplit ; nvm_echo $?)"; setopt shwordsplit; fi; local LTS_ARG; if [ -n "${NVM_LTS-}" ]; then LTS_ARG="--lts=${NVM_LTS-}"; VERSION=''; fi; if [ "_$VERSION" = "_N/A" ]; then nvm_ensure_version_installed "$provided_version"; else if [ "$NVM_IOJS" = true ]; then nvm exec "${NVM_SILENT-}" "${LTS_ARG-}" "$VERSION" iojs "$@"; else nvm exec "${NVM_SILENT-}" "${LTS_ARG-}" "$VERSION" node "$@"; fi; fi; EXIT_CODE="$?"; if [ "$ZSH_HAS_SHWORDSPLIT_UNSET" -eq 1 ] && nvm_has "unsetopt"; then unsetopt shwordsplit; fi; return $EXIT_CODE ;; "exec") local NVM_SILENT; local NVM_LTS; while [ $# -gt 0 ]; do case "$1" in --silent) NVM_SILENT='--silent'; shift ;; --lts) NVM_LTS='*'; shift ;; --lts=*) NVM_LTS="${1##--lts=}"; shift ;; --) break ;; --*) nvm_err "Unsupported option \"$1\"."; return 55 ;; *) if [ -n "$1" ]; then break; else shift; fi ;; esac; done; local provided_version; provided_version="$1"; if [ "${NVM_LTS-}" != '' ]; then provided_version="lts/${NVM_LTS:-*}"; VERSION="$provided_version"; else if [ -n "$provided_version" ]; then VERSION="$(nvm_version "$provided_version")" || :; if [ "_$VERSION" = '_N/A' ] && ! nvm_is_valid_version "$provided_version"; then if [ -n "${NVM_SILENT-}" ]; then nvm_rc_version > /dev/null 2>&1; else nvm_rc_version; fi; provided_version="$NVM_RC_VERSION"; unset NVM_RC_VERSION; VERSION="$(nvm_version "$provided_version")" || :; else shift; fi; fi; fi; nvm_ensure_version_installed "$provided_version"; EXIT_CODE=$?; if [ "$EXIT_CODE" != "0" ]; then return $EXIT_CODE; fi; if [ -z "${NVM_SILENT-}" ]; then if [ "${NVM_LTS-}" = '*' ]; then nvm_echo "Running node latest LTS -> $(nvm_version "$VERSION")$(nvm use --silent "$VERSION" && nvm_print_npm_version)"; else if [ -n "${NVM_LTS-}" ]; then nvm_echo "Running node LTS \"${NVM_LTS-}\" -> $(nvm_version "$VERSION")$(nvm use --silent "$VERSION" && nvm_print_npm_version)"; else if nvm_is_iojs_version "$VERSION"; then nvm_echo "Running io.js $(nvm_strip_iojs_prefix "$VERSION")$(nvm use --silent "$VERSION" && nvm_print_npm_version)"; else nvm_echo "Running node $VERSION$(nvm use --silent "$VERSION" && nvm_print_npm_version)"; fi; fi; fi; fi; NODE_VERSION="$VERSION" "$NVM_DIR/nvm-exec" "$@" ;; "ls" | "list") local PATTERN; local NVM_NO_COLORS; while [ $# -gt 0 ]; do case "${1}" in --) ;; --no-colors) NVM_NO_COLORS="${1}" ;; --*) nvm_err "Unsupported option \"${1}\"."; return 55 ;; *) PATTERN="${PATTERN:-$1}" ;; esac; shift; done; local NVM_LS_OUTPUT; local NVM_LS_EXIT_CODE; NVM_LS_OUTPUT=$(nvm_ls "${PATTERN-}"); NVM_LS_EXIT_CODE=$?; NVM_NO_COLORS="${NVM_NO_COLORS-}" nvm_print_versions "$NVM_LS_OUTPUT"; if [ -z "${PATTERN-}" ]; then if [ -n "${NVM_NO_COLORS-}" ]; then nvm alias --no-colors; else nvm alias; fi; fi; return $NVM_LS_EXIT_CODE ;; "ls-remote" | "list-remote") local NVM_LTS; local PATTERN; local NVM_NO_COLORS; while [ $# -gt 0 ]; do case "${1-}" in --) ;; --lts) NVM_LTS='*' ;; --lts=*) NVM_LTS="${1##--lts=}" ;; --no-colors) NVM_NO_COLORS="${1}" ;; --*) nvm_err "Unsupported option \"${1}\"."; return 55 ;; *) if [ -z "${PATTERN-}" ]; then PATTERN="${1-}"; if [ -z "${NVM_LTS-}" ]; then case "${PATTERN}" in 'lts/*') NVM_LTS='*' ;; lts/*) NVM_LTS="${PATTERN##lts/}" ;; esac; fi; fi ;; esac; shift; done; local NVM_OUTPUT; local EXIT_CODE; NVM_OUTPUT="$(NVM_LTS="${NVM_LTS-}" nvm_remote_versions "${PATTERN}" &&:)"; EXIT_CODE=$?; if [ -n "$NVM_OUTPUT" ]; then NVM_NO_COLORS="${NVM_NO_COLORS-}" nvm_print_versions "$NVM_OUTPUT"; return $EXIT_CODE; fi; NVM_NO_COLORS="${NVM_NO_COLORS-}" nvm_print_versions "N/A"; return 3 ;; "current") nvm_version current ;; "which") local provided_version; provided_version="${1-}"; if [ $# -eq 0 ]; then nvm_rc_version; if [ -n "${NVM_RC_VERSION}" ]; then provided_version="${NVM_RC_VERSION}"; VERSION=$(nvm_version "${NVM_RC_VERSION}") || :; fi; unset NVM_RC_VERSION; else if [ "_${1}" != '_system' ]; then VERSION="$(nvm_version "${provided_version}")" || :; else VERSION="${1-}"; fi; fi; if [ -z "${VERSION}" ]; then nvm --help 1>&2; return 127; fi; if [ "_$VERSION" = '_system' ]; then if nvm_has_system_iojs > /dev/null 2>&1 || nvm_has_system_node > /dev/null 2>&1; then local NVM_BIN; NVM_BIN="$(nvm use system >/dev/null 2>&1 && command which node)"; if [ -n "$NVM_BIN" ]; then nvm_echo "$NVM_BIN"; return; fi; return 1; fi; nvm_err 'System version of node not found.'; return 127; else if [ "_$VERSION" = "_∞" ]; then nvm_err "The alias \"$2\" leads to an infinite loop. Aborting."; return 8; fi; fi; nvm_ensure_version_installed "$provided_version"; EXIT_CODE=$?; if [ "$EXIT_CODE" != "0" ]; then return $EXIT_CODE; fi; local NVM_VERSION_DIR; NVM_VERSION_DIR="$(nvm_version_path "$VERSION")"; nvm_echo "$NVM_VERSION_DIR/bin/node" ;; "alias") local NVM_ALIAS_DIR; NVM_ALIAS_DIR="$(nvm_alias_path)"; local NVM_CURRENT; NVM_CURRENT="$(nvm_ls_current)"; command mkdir -p "${NVM_ALIAS_DIR}/lts"; local ALIAS; local TARGET; local NVM_NO_COLORS; ALIAS='--'; TARGET='--'; while [ $# -gt 0 ]; do case "${1-}" in --) ;; --no-colors) NVM_NO_COLORS="${1}" ;; --*) nvm_err "Unsupported option \"${1}\"."; return 55 ;; *) if [ "${ALIAS}" = '--' ]; then ALIAS="${1-}"; else if [ "${TARGET}" = '--' ]; then TARGET="${1-}"; fi; fi ;; esac; shift; done; if [ -z "${TARGET}" ]; then nvm unalias "${ALIAS}"; return $?; else if [ "${TARGET}" != '--' ]; then if [ "${ALIAS#*\/}" != "${ALIAS}" ]; then nvm_err 'Aliases in subdirectories are not supported.'; return 1; fi; VERSION="$(nvm_version "${TARGET}")" || :; if [ "${VERSION}" = 'N/A' ]; then nvm_err "! WARNING: Version '${TARGET}' does not exist."; fi; nvm_make_alias "${ALIAS}" "${TARGET}"; NVM_NO_COLORS="${NVM_NO_COLORS-}" NVM_CURRENT="${NVM_CURRENT-}" DEFAULT=false nvm_print_formatted_alias "${ALIAS}" "${TARGET}" "$VERSION"; else if [ "${ALIAS-}" = '--' ]; then unset ALIAS; fi; nvm_list_aliases "${ALIAS-}"; fi; fi ;; "unalias") local NVM_ALIAS_DIR; NVM_ALIAS_DIR="$(nvm_alias_path)"; command mkdir -p "$NVM_ALIAS_DIR"; if [ $# -ne 1 ]; then nvm --help 1>&2; return 127; fi; if [ "${1#*\/}" != "${1-}" ]; then nvm_err 'Aliases in subdirectories are not supported.'; return 1; fi; [ ! -f "$NVM_ALIAS_DIR/${1-}" ] && nvm_err "Alias ${1-} doesn't exist!" && return; local NVM_ALIAS_ORIGINAL; NVM_ALIAS_ORIGINAL="$(nvm_alias "${1}")"; command rm -f "$NVM_ALIAS_DIR/${1}"; nvm_echo "Deleted alias ${1} - restore it with \`nvm alias \"${1}\" \"$NVM_ALIAS_ORIGINAL\"\`" ;; "install-latest-npm") if [ $# -ne 0 ]; then nvm --help 1>&2; return 127; fi; nvm_install_latest_npm ;; "reinstall-packages" | "copy-packages") if [ $# -ne 1 ]; then nvm --help 1>&2; return 127; fi; local PROVIDED_VERSION; PROVIDED_VERSION="${1-}"; if [ "$PROVIDED_VERSION" = "$(nvm_ls_current)" ] || [ "$(nvm_version "$PROVIDED_VERSION" ||:)" = "$(nvm_ls_current)" ]; then nvm_err 'Can not reinstall packages from the current version of node.'; return 2; fi; local VERSION; if [ "_$PROVIDED_VERSION" = "_system" ]; then if ! nvm_has_system_node && ! nvm_has_system_iojs; then nvm_err 'No system version of node or io.js detected.'; return 3; fi; VERSION="system"; else VERSION="$(nvm_version "$PROVIDED_VERSION")" || :; fi; local NPMLIST; NPMLIST="$(nvm_npm_global_modules "$VERSION")"; local INSTALLS; local LINKS; INSTALLS="${NPMLIST%% //// *}"; LINKS="${NPMLIST##* //// }"; nvm_echo "Reinstalling global packages from $VERSION..."; if [ -n "${INSTALLS}" ]; then nvm_echo "$INSTALLS" | command xargs npm install -g --quiet; else nvm_echo "No installed global packages found..."; fi; nvm_echo "Linking global packages from $VERSION..."; if [ -n "${LINKS}" ]; then ( set -f; IFS=' '; for LINK in $LINKS; do set +f; unset IFS; if [ -n "$LINK" ]; then ( nvm_cd "$LINK" && npm link ); fi; done ); else nvm_echo "No linked global packages found..."; fi ;; "clear-cache") command rm -f "$NVM_DIR/v*" "$(nvm_version_dir)" 2> /dev/null; nvm_echo 'nvm cache cleared.' ;; "version") nvm_version "${1}" ;; "version-remote") local NVM_LTS; local PATTERN; while [ $# -gt 0 ]; do case "${1-}" in --) ;; --lts) NVM_LTS='*' ;; --lts=*) NVM_LTS="${1##--lts=}" ;; --*) nvm_err "Unsupported option \"${1}\"."; return 55 ;; *) PATTERN="${PATTERN:-${1}}" ;; esac; shift; done; case "${PATTERN}" in 'lts/*') NVM_LTS='*'; unset PATTERN ;; lts/*) NVM_LTS="${PATTERN##lts/}"; unset PATTERN ;; esac; NVM_VERSION_ONLY=true NVM_LTS="${NVM_LTS-}" nvm_remote_version "${PATTERN:-node}" ;; "--version") nvm_echo '0.33.11' ;; "unload") nvm deactivate > /dev/null 2>&1; unset -f nvm nvm_iojs_prefix nvm_node_prefix nvm_add_iojs_prefix nvm_strip_iojs_prefix nvm_is_iojs_version nvm_is_alias nvm_has_non_aliased nvm_ls_remote nvm_ls_remote_iojs nvm_ls_remote_index_tab nvm_ls nvm_remote_version nvm_remote_versions nvm_install_binary nvm_install_source nvm_clang_version nvm_get_mirror nvm_get_download_slug nvm_download_artifact nvm_install_npm_if_needed nvm_use_if_needed nvm_check_file_permissions nvm_print_versions nvm_compute_checksum nvm_checksum nvm_get_checksum_alg nvm_get_checksum nvm_compare_checksum nvm_version nvm_rc_version nvm_match_version nvm_ensure_default_set nvm_get_arch nvm_get_os nvm_print_implicit_alias nvm_validate_implicit_alias nvm_resolve_alias nvm_ls_current nvm_alias nvm_binary_available nvm_change_path nvm_strip_path nvm_num_version_groups nvm_format_version nvm_ensure_version_prefix nvm_normalize_version nvm_is_valid_version nvm_ensure_version_installed nvm_cache_dir nvm_version_path nvm_alias_path nvm_version_dir nvm_find_nvmrc nvm_find_up nvm_tree_contains_path nvm_version_greater nvm_version_greater_than_or_equal_to nvm_print_npm_version nvm_install_latest_npm nvm_npm_global_modules nvm_has_system_node nvm_has_system_iojs nvm_download nvm_get_latest nvm_has nvm_install_default_packages nvm_curl_use_compression nvm_curl_version nvm_supports_source_options nvm_auto nvm_supports_xz nvm_echo nvm_err nvm_grep nvm_cd nvm_die_on_prefix nvm_get_make_jobs nvm_get_minor_version nvm_has_solaris_binary nvm_is_merged_node_version nvm_is_natural_num nvm_is_version_installed nvm_list_aliases nvm_make_alias nvm_print_alias_path nvm_print_default_alias nvm_print_formatted_alias nvm_resolve_local_alias nvm_sanitize_path nvm_has_colors nvm_process_parameters node_version_has_solaris_binary iojs_version_has_solaris_binary nvm_curl_libz_support nvm_command_info > /dev/null 2>&1; unset NVM_RC_VERSION NVM_NODEJS_ORG_MIRROR NVM_IOJS_ORG_MIRROR NVM_DIR NVM_CD_FLAGS NVM_BIN NVM_MAKE_JOBS > /dev/null 2>&1 ;; *) nvm --help 1>&2; return 127 ;; esac } nvm_add_iojs_prefix () { nvm_echo "$(nvm_iojs_prefix)-$(nvm_ensure_version_prefix "$(nvm_strip_iojs_prefix "${1-}")")" } nvm_alias () { local ALIAS; ALIAS="${1-}"; if [ -z "${ALIAS}" ]; then nvm_err 'An alias is required.'; return 1; fi; local NVM_ALIAS_PATH; NVM_ALIAS_PATH="$(nvm_alias_path)/${ALIAS}"; if [ ! -f "${NVM_ALIAS_PATH}" ]; then nvm_err 'Alias does not exist.'; return 2; fi; command cat "${NVM_ALIAS_PATH}" } nvm_alias_path () { nvm_echo "$(nvm_version_dir old)/alias" } nvm_auto () { local NVM_MODE; NVM_MODE="${1-}"; local VERSION; if [ "_$NVM_MODE" = '_install' ]; then VERSION="$(nvm_alias default 2>/dev/null || nvm_echo)"; if [ -n "$VERSION" ]; then nvm install "$VERSION" > /dev/null; else if nvm_rc_version > /dev/null 2>&1; then nvm install > /dev/null; fi; fi; else if [ "_$NVM_MODE" = '_use' ]; then VERSION="$(nvm_resolve_local_alias default 2>/dev/null || nvm_echo)"; if [ -n "$VERSION" ]; then nvm use --silent "$VERSION" > /dev/null; else if nvm_rc_version > /dev/null 2>&1; then nvm use --silent > /dev/null; fi; fi; else if [ "_$NVM_MODE" != '_none' ]; then nvm_err 'Invalid auto mode supplied.'; return 1; fi; fi; fi } nvm_binary_available () { nvm_version_greater_than_or_equal_to "$(nvm_strip_iojs_prefix "${1-}")" v0.8.6 } nvm_cache_dir () { nvm_echo "${NVM_DIR}/.cache" } nvm_cd () { \cd "$@" } nvm_change_path () { if [ -z "${1-}" ]; then nvm_echo "${3-}${2-}"; else if ! nvm_echo "${1-}" | nvm_grep -q "${NVM_DIR}/[^/]*${2-}" && ! nvm_echo "${1-}" | nvm_grep -q "${NVM_DIR}/versions/[^/]*/[^/]*${2-}"; then nvm_echo "${3-}${2-}:${1-}"; else nvm_echo "${1-}" | command sed -e "s#${NVM_DIR}/[^/]*${2-}[^:]*#${3-}${2-}#g" -e "s#${NVM_DIR}/versions/[^/]*/[^/]*${2-}[^:]*#${3-}${2-}#g"; fi; fi } nvm_check_file_permissions () { local ZSH_HAS_NONOMATCH_UNSET; ZSH_HAS_NONOMATCH_UNSET=1; if nvm_has "setopt"; then ZSH_HAS_NONOMATCH_UNSET="$(set +e ; setopt | nvm_grep -q nonomatch ; nvm_echo $?)"; setopt nonomatch; fi; for FILE in $1/* $1/.[!.]* $1/..?*; do if [ -d "$FILE" ]; then if ! nvm_check_file_permissions "$FILE"; then if [ "${ZSH_HAS_NONOMATCH_UNSET}" -eq 1 ] && nvm_has "setopt"; then setopt nomatch; fi; return 2; fi; else if [ -e "$FILE" ] && [ ! -w "$FILE" ] && [ ! -O "$FILE" ]; then nvm_err "file is not writable or self-owned: $(nvm_sanitize_path "$FILE")"; if [ "${ZSH_HAS_NONOMATCH_UNSET}" -eq 1 ] && nvm_has "setopt"; then setopt nomatch; fi; return 1; fi; fi; done; if [ "${ZSH_HAS_NONOMATCH_UNSET}" -eq 1 ] && nvm_has "setopt"; then setopt nomatch; fi; return 0 } nvm_checksum () { local NVM_CHECKSUM; if [ -z "${3-}" ] || [ "${3-}" = 'sha1' ]; then if nvm_has_non_aliased "sha1sum"; then NVM_CHECKSUM="$(command sha1sum "${1-}" | command awk '{print $1}')"; else if nvm_has_non_aliased "sha1"; then NVM_CHECKSUM="$(command sha1 -q "${1-}")"; else if nvm_has_non_aliased "shasum"; then NVM_CHECKSUM="$(command shasum "${1-}" | command awk '{print $1}')"; else nvm_err 'Unaliased sha1sum, sha1, or shasum not found.'; return 2; fi; fi; fi; else if nvm_has_non_aliased "sha256sum"; then NVM_CHECKSUM="$(command sha256sum "${1-}" | command awk '{print $1}')"; else if nvm_has_non_aliased "shasum"; then NVM_CHECKSUM="$(command shasum -a 256 "${1-}" | command awk '{print $1}')"; else if nvm_has_non_aliased "sha256"; then NVM_CHECKSUM="$(command sha256 -q "${1-}" | command awk '{print $1}')"; else if nvm_has_non_aliased "gsha256sum"; then NVM_CHECKSUM="$(command gsha256sum "${1-}" | command awk '{print $1}')"; else if nvm_has_non_aliased "openssl"; then NVM_CHECKSUM="$(command openssl dgst -sha256 "${1-}" | command awk '{print $NF}')"; else if nvm_has_non_aliased "bssl"; then NVM_CHECKSUM="$(command bssl sha256sum "${1-}" | command awk '{print $1}')"; else nvm_err 'Unaliased sha256sum, shasum, sha256, gsha256sum, openssl, or bssl not found.'; nvm_err 'WARNING: Continuing *without checksum verification*'; return; fi; fi; fi; fi; fi; fi; fi; if [ "_${NVM_CHECKSUM}" = "_${2-}" ]; then return; else if [ -z "${2-}" ]; then …
1 parent 00cf7ac commit 833cca0

32 files changed

+1447
-1013
lines changed

doc/can-query-logic.md

Lines changed: 362 additions & 393 deletions
Large diffs are not rendered by default.

doc/etc.md

Lines changed: 0 additions & 86 deletions
This file was deleted.

doc/examples/date-string-example.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import {DefineMap, QueryLogic, Reflect as canReflect} from "can";
2+
3+
class DateStringSet {
4+
constructor(value){
5+
this.value = value;
6+
}
7+
// used to convert to a number
8+
valueOf(){
9+
return new Date(this.value).getTime();
10+
}
11+
}
12+
13+
canReflect.assignSymbols(DateStringSet.prototype,{
14+
"can.serialize": function(){
15+
return this.value;
16+
}
17+
});
18+
19+
const DateString = {
20+
[Symbol.for("can.SetType")]: DateStringSet
21+
};
22+
23+
const Todo = DefineMap.extend({
24+
id: {type: "number", identity: true},
25+
name: "string",
26+
date: DateString
27+
});
28+
29+
const queryLogic = new QueryLogic(Todo);
30+
31+
const filter = queryLogic.filterMembers(
32+
{filter: {date: {$gt: "Wed Apr 04 2018 10:00:00 GMT-0500 (CDT)"}}},
33+
[{id: 1, name: "grab coffee", date: "Wed Apr 03 2018 10:00:00 GMT-0500 (CDT)"},
34+
{id: 2, name: "finish these docs", date: "Thurs Apr 05 2018 10:00:00 GMT-0500 (CDT)"},
35+
{id: 3, name: "Learn CanJS", date: "Thurs Apr 05 2017 10:00:00 GMT-0500 (CDT)"}]
36+
);
37+
38+
console.log(filter); //-> {
39+
// id: 2,
40+
// name: "finish these docs",
41+
// date: "Wed Apr 05 2018 10:00:00 GMT-0500 (CDT)"
42+
// }

doc/examples/recipe-example.js

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import {QueryLogic, Reflect as canReflect} from "can";
2+
3+
// Takes the value of `name` (ex: `"chicken"`)
4+
function SearchableStringSet(value) {
5+
this.value = value;
6+
}
7+
8+
canReflect.assignSymbols(SearchableStringSet.prototype,{
9+
// Returns if the name on a todo is actually a member of the set.
10+
"can.isMember": function(value){
11+
return value.includes(this.value);
12+
},
13+
// Converts back to a value that can be in a query.
14+
"can.serialize": function(){
15+
return this.value;
16+
}
17+
});
18+
19+
// Specify how to do the fundamental set comparisons.
20+
QueryLogic.defineComparison(SearchableStringSet,SearchableStringSet,{
21+
// Return a set that would load all records in searchA and searchB.
22+
union(searchA, searchB){
23+
// If searchA's text contains searchB's text, then
24+
// searchB will include searchA's results.
25+
if(searchA.value.includes(searchB.value)) {
26+
// A:`food` ∪ B:`foo` => `foo`
27+
return searchB;
28+
}
29+
if(searchB.value.includes(searchA.value)) {
30+
// A:`foo` ∪ B:`food` => `foo`
31+
return searchA;
32+
}
33+
// A:`ice` ∪ B:`cream` => `ice` || `cream`
34+
return new QueryLogic.ValueOr([searchA, searchB]);
35+
},
36+
// Return a set that would load records shared by searchA and searchB.
37+
intersection(searchA, searchB){
38+
// If searchA's text contains searchB's text, then
39+
// searchA is the shared search results.
40+
if(searchA.value.includes(searchB.value)) {
41+
// A:`food` ∩ B:`foo` => `food`
42+
return searchA;
43+
}
44+
if(searchB.value.includes(searchA.value)) {
45+
// A:`foo` ∩ B:`food` => `food`
46+
return searchB;
47+
}
48+
// A:`ice` ∩ B:`cream` => `ice` && `cream`
49+
// But suppose AND isn't supported,
50+
// So we return `UNDEFINABLE`.
51+
return QueryLogic.UNDEFINABLE;
52+
},
53+
// Return a set that would load records in searchA that are not in
54+
// searchB.
55+
difference(searchA, searchB){
56+
// if searchA's text contains searchB's text, then
57+
// searchA has nothing outside what searchB would return.
58+
if(searchA.value.includes(searchB.value)) {
59+
// A:`food` \ B:`foo` => ∅
60+
return QueryLogic.EMPTY;
61+
}
62+
// If searchA has results outside searchB's results
63+
// then there are records, but we aren't able to
64+
// create a string that represents this.
65+
if(searchB.value.includes(searchA.value)) {
66+
// A:`foo` \ B:`food` => UNDEFINABLE
67+
return QueryLogic.UNDEFINABLE;
68+
}
69+
70+
// A:`ice` \ B:`cream` => `ice` && !`cream`
71+
// If there's another situation, we
72+
// aren't able to express the difference
73+
// so we return UNDEFINABLE.
74+
return QueryLogic.UNDEFINABLE;
75+
}
76+
});
77+
78+
const recipes = [
79+
{id: 1, name: "garlic chicken"},
80+
{id: 2, name: "ice cream"},
81+
{id: 3, name: "chicken kiev"}
82+
];
83+
84+
const queryLogic = new QueryLogic({ keys: {
85+
name : {[Symbol.for("can.SetType")]: SearchableStringSet}
86+
}});
87+
88+
const result = queryLogic.filterMembers({
89+
filter: {name: "chicken"}
90+
}, recipes);
91+
92+
console.log( result ); //-> [
93+
// {id: 1, name: "garlic chicken"},
94+
// {id: 3, name: "chicken kiev"}
95+
// ]
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import {DefineMap, QueryLogic, Reflect as canReflect} from "can";
2+
3+
// Takes the value of `name` (ex: `"chicken"`)
4+
function SearchableStringSet(value) {
5+
this.value = value;
6+
}
7+
8+
canReflect.assignSymbols(SearchableStringSet.prototype,{
9+
// Returns if the name on a todo is actually a member of the set.
10+
"can.isMember": function(value){
11+
return value.includes(this.value);
12+
},
13+
// Converts back to a value that can be in a query.
14+
"can.serialize": function(){
15+
return this.value;
16+
}
17+
});
18+
19+
// Specify how to do the fundamental set comparisons.
20+
QueryLogic.defineComparison(SearchableStringSet,SearchableStringSet,{
21+
// Return a set that would load all records in searchA and searchB.
22+
union(searchA, searchB){
23+
// If searchA's text contains searchB's text, then
24+
// searchB will include searchA's results.
25+
if(searchA.value.includes(searchB.value)) {
26+
// A:`food` ∪ B:`foo` => `foo`
27+
return searchB;
28+
}
29+
if(searchB.value.includes(searchA.value)) {
30+
// A:`foo` ∪ B:`food` => `foo`
31+
return searchA;
32+
}
33+
// A:`ice` ∪ B:`cream` => `ice` || `cream`
34+
return new QueryLogic.ValueOr([searchA, searchB]);
35+
},
36+
// Return a set that would load records shared by searchA and searchB.
37+
intersection(searchA, searchB){
38+
// If searchA's text contains searchB's text, then
39+
// searchA is the shared search results.
40+
if(searchA.value.includes(searchB.value)) {
41+
// A:`food` ∩ B:`foo` => `food`
42+
return searchA;
43+
}
44+
if(searchB.value.includes(searchA.value)) {
45+
// A:`foo` ∩ B:`food` => `food`
46+
return searchB;
47+
}
48+
// A:`ice` ∩ B:`cream` => `ice` && `cream`
49+
// But suppose AND isn't supported,
50+
// So we return `UNDEFINABLE`.
51+
return QueryLogic.UNDEFINABLE;
52+
},
53+
// Return a set that would load records in searchA that are not in
54+
// searchB.
55+
difference(searchA, searchB){
56+
// if searchA's text contains searchB's text, then
57+
// searchA has nothing outside what searchB would return.
58+
if(searchA.value.includes(searchB.value)) {
59+
// A:`food` \ B:`foo` => ∅
60+
return QueryLogic.EMPTY;
61+
}
62+
// If searchA has results outside searchB's results
63+
// then there are records, but we aren't able to
64+
// create a string that represents this.
65+
if(searchB.value.includes(searchA.value)) {
66+
// A:`foo` \ B:`food` => UNDEFINABLE
67+
return QueryLogic.UNDEFINABLE;
68+
}
69+
70+
// A:`ice` \ B:`cream` => `ice` && !`cream`
71+
// If there's another situation, we
72+
// aren't able to express the difference
73+
// so we return UNDEFINABLE.
74+
return QueryLogic.UNDEFINABLE;
75+
}
76+
});
77+
78+
const SearchableString = {
79+
[Symbol.for("can.SetType")]: SearchableStringSet
80+
};
81+
82+
const Todo = DefineMap.extend({
83+
id: {type: "number", identity: true},
84+
name: SearchableString,
85+
});
86+
87+
const todos = [
88+
{id: 1, name: "important meeting"},
89+
{id: 2, name: "fall asleep during meeting"},
90+
{id: 3, name: "find out what important means"}
91+
];
92+
93+
const queryLogic = new QueryLogic(Todo);
94+
95+
const result = queryLogic.filterMembers({
96+
filter: {name: "important"}
97+
}, todos);
98+
99+
console.log( todos ); //->[{id: 1, name: "important meeting"},{id: 3, name: "find out what important means"}]
100+

doc/examples/todo-example.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import {DefineMap, QueryLogic} from "can";
2+
3+
const Todo = DefineMap.extend({
4+
id: {
5+
identity: true,
6+
type: "number"
7+
},
8+
name: "string",
9+
complete: "boolean"
10+
});
11+
12+
const todoQueryLogic = new QueryLogic(Todo);
13+
14+
const filter = todoQueryLogic.filterMembers({
15+
filter: {
16+
complete: false
17+
},
18+
sort: "-name",
19+
page: {start: 0, end: 19}
20+
},[
21+
{id: 1, name: "do dishes", complete: false},
22+
{id: 2, name: "mow lawn", complete: true},
23+
// ...
24+
]);
25+
console.log( filter ); //-> [{id: 1, name: "do dishes", complete: false}]

doc/examples/todo-union-example.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import {DefineMap, QueryLogic} from "can";
2+
3+
const Todo = DefineMap.extend({
4+
id: {
5+
identity: true,
6+
type: "number"
7+
},
8+
name: "string",
9+
complete: "boolean"
10+
});
11+
12+
const todoQueryLogic = new QueryLogic(Todo);
13+
14+
const unionization = todoQueryLogic.union(
15+
{ filter: {name: "assigned"} },
16+
{ filter: {name: "complete"} }
17+
);
18+
19+
console.log( JSON.stringify(unionization) ); //-> "{'filter':{'name':{'$in':['assigned','complete']}}}"

0 commit comments

Comments
 (0)