123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- node --version
- npm --version
- npx --version
- Creating static data visualizations with D3 & Node -
- https://www.pyktech.com/blog/150/
- https://bl.ocks.org/pykerl/10907334
- D3.js Graph Gallery - https://d3-graph-gallery.com/
- D3.js Playbook - https://grammer.github.io/d3js-playbook/index.html
- Interactive Charts with D3.js -
- https://wattenberger.com/blog/d3-interactive-charts
- # update version of npm:
- sudo npm install -g npm # to update globally
- # install npm modules
- npm install validator # to install the latest version of the module validator
- npm install validator@10.8.0 # to install the version 10.8.0 of the module validator
- # install global npm modules
- npm install -g nodemon # to install the latest version of the module nodemon globally
- npm install -g nodemon@1.18.5 # to install the version 1.18.5 of the module nodemon
- # Formatting console output
- Specifier Ouput
- %s Formats the value as a string
- %i or %d Formats the value as an integer
- %f Formats the value as a floating point value
- %o Formats the value as an expandable DOM element
- %O Formats the value as an expandable JavaScript object
- %c Applies CSS style rules to the output string as specified by the second parameter
- console.log('%s has %d points', 'Sam', 100);
- # global (/usr/local/lib)
- sudo npm install -g d3
- npm list -g
- sudo npm update -g
- sudo npm uninstall -g d3
- # 16 npm commands:
- 1. Install a package in the package.json file in the local node_modules directory:
- npm install
- 2. Remove a package from the package.json file and removes the module from the local
- node_modules directory:
- npm uninstall
- 3. Update the specified package. If no package is specified then it updates all the
- packages in the specified location:
- npm update
- 4. Apply the update action to each globally installed package:
- npm update -g
- 5. Deprecate the npm registry for a package, providing a deprecation warning to all who
- attempt to install it:
- npm deprecate
- 6. Checks the registry if any (or specified) package is outdated. It prints a list of all
- packages which are outdated:
- npm outdated
- 7. Checks our environment so that our npm installation has what it needs to manage our
- JavaScript packages:
- npm doctor
- 8. Creates a package.json file in our directory. It basically asks some questions and
- finally creates a package.json file in the current project directory:
- npm init
- 9. Runs a command that is defined in the start property in the scripts. If not defined it
- will run the node server.js command:
- npm start
- 10. It is used to build a package:
- npm build
- 11. Lists all the packages as well as their dependencies installed:
- npm ls
- 12. Bumps a package version:
- npm version
- 13. Searches the npm registry for packages matching the search terms:
- npm search
- 14. Searches npm help documentation for a specified topic. It is used whenever the user
- needs help to get some reference:
- npm help
- 15. Manages ownership of published packages. It is used to manage package owners:
- npm owner
- 16. Definitive documentation on these fields:
- npm help init
- # reserved words:
- abstract
- boolean break byte
- case catch chat class const continue
- debugger default delete do double
- else enum export extends
- false final finally float for function
- goto
- if implements import in instanceof int interface
- long
- native new null
- package private protected public
- return
- short static super switch synchronized
- this throw throws transient true try typeof
- # type of the variable
- const N = 1000;
- console.log(typeof(N));
- var volatile void
- while with
- # deno [https://deno.land/manual@v1.35.2/getting_started/installation]
- deno is a single binary executable. It has no external dependencies.
- installation:
- $ curl -fsSL https://deno.land/x/install/install.sh | sh
- updating: To update a previously installed version of deno, you can run
- $ deno upgrade
- To install a specific version of deno: $ deno upgrade --version 1.0.1
- $ deno --help
- $ deno --version
- $ deno run file.js
- $ deno check file.js # type-check code (without executing it)
- $ deno run --check file.js # type-check code before execution
- # dpm (deno package manager) [https://dpmland-docs.netlify.app/]
- dpm is a cli tool that helps you with your deno projects.
- installation:
- $ deno install --allow-all --unstable -f -n dpm https://deno.land/x/denopm/mod.ts
- $ dpm init # create a new project
- $ dpm minify # minify your project
- $ dpm <script name> # run scripts in your project
- $ dpm update # update
- # start a basic deno project:mega:
- For start a deno project with all files you only need make this:
- $ mkdir project && cd project # start a new project directory
- $ dpm init -A # start a all fully featured dpm project (answer the questions & done)
- If you just need to start dpm_imports.json and dpm.json files without questions
- you need to run:
- $ mkdir project && cd project # start a new project directory
- $ dpm init -y # start only necessary files project
- If you want to restart or only write one file you need to run:
- $ mkdir project && cd project # start a new project directory
- $ dpm init -f readme # start only one file
- Note: Check the files avaliable on dpm init help for start a file like: readme,
- deno-config or eggs you need start the dpm.json file.
- # install dependencies with dpm:package:
- deno does not download files on the computer, only write the correct url at
- dpm_imports.json and make an experience of development like nodejs with npm.
- For install dependencies form the deno.land/x registry you only need to write:
- $ dpm install draco dlog2
- For install dependencies from the Deno std registry you only need to use this:
- $ dpm install flag async http path --std
- Note: you need put the name of the library and the flag -s or --std
- For install dependencies from other host or registries you need to run:
- $ dpm install example_dep --host nest.land
- # use the dependencies with pem:package:
- To use the modules installed at dpm_imports.json, you need to use like node:
- import { serve } from "http/server.ts";
- serve((req) => new Response("Hello World\n"));
- Note: To configure dpm to work with code editors, you need to download the
- plugin for your editor and fill the deno.config field at ./deno.json and the
- deno.importMap field at ./dpm_imports.json
- # uninstall dependencies with dpm:star2:
- dpm does not delete any libraries from your computer, it just deletes the
- dpm_imports.json file.
- To uninstall all dependencies at dpm_imports.json you need to run:
- $ dpm uninstall -A
- For uninstall just one specific dependency you need to run:
- $ dpm uninstall draco dlog2
- # automate commands with deno tasks
- Many apps need some commands, and you do not like write this many times this
- command and here are the amazing and incredible deno tasks well with this you
- can automate many things and are integrated with deno but how can make this
- amazing tool better here are the task command on dpm.
- To add a task to the files well you only need to run:
- $ dpm task -n
- And this adds the task at deno.json and dpm.json, well but if I add a new task
- at dpm.json how can update this? You only need to run this command:
- $ dpm task -u
- You want to see what commands you have, and this files here are the list in a
- beautiful table.
- $ dpm task -l deno # to see the deno.json file
- $ dpm task -l dpm # to see the dpm.json file
- $ dpm task -l all # to see the dpm and deno.json files
- Note: Here are all basic features of dpm if you want to but exists more features
- you can check dpm doc help:white_check_mark:
- # features
- * deno lint and deno fmt commands support
- * config generator for deno lint, deno fmt and deno test
- * manage all in a dpm.json file with the same syntax of the package.json
- * generate all dependencies from a import_map.json file
- # install npm package in deno with dpm
- $ mkdir matterjs && cd matterjs
- $ dpm init -A
- $ dpm install npm:matter-js
- # javascript keywords
- arguments else in super
- await enum instanceof switch
- break eval interface this
- case export let throw
- catch extends new true
- class false null try
- const finally package typeof
- continue for private var
- debugger function protected void
- default if public while
- delete implements return with
- do import static yield
- # math
- The Math class supplies the constants Math.E, Math.PI, Math.LN2, and Math.LN10.
- Some of the methods supplied by the Math class are:
- Math.abs(x) - Returns the absolute value of x
- Math.sign(x) - Returns the one of -1, 0, or 1 that has the same sign as x
- Math.trunc(x) - Returns the integer portion of x
- Math.round(x) - Returns the integer nearest to x
- Math.floor(x) - Returns the largest integer less than or equal to x
- Math.ceil(x) - Returns the smallest integer greater than or equal to x
- Math.max(x1,x2,...,xN) - Returns the largest of its arguments
- Math.min(x1,x2,...,xN) - Returns the smallest of its arguments
- Math.sqrt(x) - Returns the positive square root of x
- Math.cbrt(x) - Returns the cube root of x
- Math.random() - Returns a pseudo-random number r in the range 0 <= r < 1
- The Math class also supplies the standard logarithmic and trignometric functions exp,
- log, log10, log2, sin, cos, tan, asin, acos, atan, as well as the hyperbolic functions
- sinh, cosh, tanh, asinh, acosh, and atanh. All angles are in radians.
|