jsref.txt 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. node --version
  2. npm --version
  3. npx --version
  4. Creating static data visualizations with D3 & Node -
  5. https://www.pyktech.com/blog/150/
  6. https://bl.ocks.org/pykerl/10907334
  7. D3.js Graph Gallery - https://d3-graph-gallery.com/
  8. D3.js Playbook - https://grammer.github.io/d3js-playbook/index.html
  9. Interactive Charts with D3.js -
  10. https://wattenberger.com/blog/d3-interactive-charts
  11. # update version of npm:
  12. sudo npm install -g npm # to update globally
  13. # install npm modules
  14. npm install validator # to install the latest version of the module validator
  15. npm install validator@10.8.0 # to install the version 10.8.0 of the module validator
  16. # install global npm modules
  17. npm install -g nodemon # to install the latest version of the module nodemon globally
  18. npm install -g nodemon@1.18.5 # to install the version 1.18.5 of the module nodemon
  19. # Formatting console output
  20. Specifier Ouput
  21. %s Formats the value as a string
  22. %i or %d Formats the value as an integer
  23. %f Formats the value as a floating point value
  24. %o Formats the value as an expandable DOM element
  25. %O Formats the value as an expandable JavaScript object
  26. %c Applies CSS style rules to the output string as specified by the second parameter
  27. console.log('%s has %d points', 'Sam', 100);
  28. # global (/usr/local/lib)
  29. sudo npm install -g d3
  30. npm list -g
  31. sudo npm update -g
  32. sudo npm uninstall -g d3
  33. # 16 npm commands:
  34. 1. Install a package in the package.json file in the local node_modules directory:
  35. npm install
  36. 2. Remove a package from the package.json file and removes the module from the local
  37. node_modules directory:
  38. npm uninstall
  39. 3. Update the specified package. If no package is specified then it updates all the
  40. packages in the specified location:
  41. npm update
  42. 4. Apply the update action to each globally installed package:
  43. npm update -g
  44. 5. Deprecate the npm registry for a package, providing a deprecation warning to all who
  45. attempt to install it:
  46. npm deprecate
  47. 6. Checks the registry if any (or specified) package is outdated. It prints a list of all
  48. packages which are outdated:
  49. npm outdated
  50. 7. Checks our environment so that our npm installation has what it needs to manage our
  51. JavaScript packages:
  52. npm doctor
  53. 8. Creates a package.json file in our directory. It basically asks some questions and
  54. finally creates a package.json file in the current project directory:
  55. npm init
  56. 9. Runs a command that is defined in the start property in the scripts. If not defined it
  57. will run the node server.js command:
  58. npm start
  59. 10. It is used to build a package:
  60. npm build
  61. 11. Lists all the packages as well as their dependencies installed:
  62. npm ls
  63. 12. Bumps a package version:
  64. npm version
  65. 13. Searches the npm registry for packages matching the search terms:
  66. npm search
  67. 14. Searches npm help documentation for a specified topic. It is used whenever the user
  68. needs help to get some reference:
  69. npm help
  70. 15. Manages ownership of published packages. It is used to manage package owners:
  71. npm owner
  72. 16. Definitive documentation on these fields:
  73. npm help init
  74. # reserved words:
  75. abstract
  76. boolean break byte
  77. case catch chat class const continue
  78. debugger default delete do double
  79. else enum export extends
  80. false final finally float for function
  81. goto
  82. if implements import in instanceof int interface
  83. long
  84. native new null
  85. package private protected public
  86. return
  87. short static super switch synchronized
  88. this throw throws transient true try typeof
  89. # type of the variable
  90. const N = 1000;
  91. console.log(typeof(N));
  92. var volatile void
  93. while with
  94. # deno [https://deno.land/manual@v1.35.2/getting_started/installation]
  95. deno is a single binary executable. It has no external dependencies.
  96. installation:
  97. $ curl -fsSL https://deno.land/x/install/install.sh | sh
  98. updating: To update a previously installed version of deno, you can run
  99. $ deno upgrade
  100. To install a specific version of deno: $ deno upgrade --version 1.0.1
  101. $ deno --help
  102. $ deno --version
  103. $ deno run file.js
  104. $ deno check file.js # type-check code (without executing it)
  105. $ deno run --check file.js # type-check code before execution
  106. # dpm (deno package manager) [https://dpmland-docs.netlify.app/]
  107. dpm is a cli tool that helps you with your deno projects.
  108. installation:
  109. $ deno install --allow-all --unstable -f -n dpm https://deno.land/x/denopm/mod.ts
  110. $ dpm init # create a new project
  111. $ dpm minify # minify your project
  112. $ dpm <script name> # run scripts in your project
  113. $ dpm update # update
  114. # start a basic deno project:mega:
  115. For start a deno project with all files you only need make this:
  116. $ mkdir project && cd project # start a new project directory
  117. $ dpm init -A # start a all fully featured dpm project (answer the questions & done)
  118. If you just need to start dpm_imports.json and dpm.json files without questions
  119. you need to run:
  120. $ mkdir project && cd project # start a new project directory
  121. $ dpm init -y # start only necessary files project
  122. If you want to restart or only write one file you need to run:
  123. $ mkdir project && cd project # start a new project directory
  124. $ dpm init -f readme # start only one file
  125. Note: Check the files avaliable on dpm init help for start a file like: readme,
  126. deno-config or eggs you need start the dpm.json file.
  127. # install dependencies with dpm:package:
  128. deno does not download files on the computer, only write the correct url at
  129. dpm_imports.json and make an experience of development like nodejs with npm.
  130. For install dependencies form the deno.land/x registry you only need to write:
  131. $ dpm install draco dlog2
  132. For install dependencies from the Deno std registry you only need to use this:
  133. $ dpm install flag async http path --std
  134. Note: you need put the name of the library and the flag -s or --std
  135. For install dependencies from other host or registries you need to run:
  136. $ dpm install example_dep --host nest.land
  137. # use the dependencies with pem:package:
  138. To use the modules installed at dpm_imports.json, you need to use like node:
  139. import { serve } from "http/server.ts";
  140. serve((req) => new Response("Hello World\n"));
  141. Note: To configure dpm to work with code editors, you need to download the
  142. plugin for your editor and fill the deno.config field at ./deno.json and the
  143. deno.importMap field at ./dpm_imports.json
  144. # uninstall dependencies with dpm:star2:
  145. dpm does not delete any libraries from your computer, it just deletes the
  146. dpm_imports.json file.
  147. To uninstall all dependencies at dpm_imports.json you need to run:
  148. $ dpm uninstall -A
  149. For uninstall just one specific dependency you need to run:
  150. $ dpm uninstall draco dlog2
  151. # automate commands with deno tasks
  152. Many apps need some commands, and you do not like write this many times this
  153. command and here are the amazing and incredible deno tasks well with this you
  154. can automate many things and are integrated with deno but how can make this
  155. amazing tool better here are the task command on dpm.
  156. To add a task to the files well you only need to run:
  157. $ dpm task -n
  158. And this adds the task at deno.json and dpm.json, well but if I add a new task
  159. at dpm.json how can update this? You only need to run this command:
  160. $ dpm task -u
  161. You want to see what commands you have, and this files here are the list in a
  162. beautiful table.
  163. $ dpm task -l deno # to see the deno.json file
  164. $ dpm task -l dpm # to see the dpm.json file
  165. $ dpm task -l all # to see the dpm and deno.json files
  166. Note: Here are all basic features of dpm if you want to but exists more features
  167. you can check dpm doc help:white_check_mark:
  168. # features
  169. * deno lint and deno fmt commands support
  170. * config generator for deno lint, deno fmt and deno test
  171. * manage all in a dpm.json file with the same syntax of the package.json
  172. * generate all dependencies from a import_map.json file
  173. # install npm package in deno with dpm
  174. $ mkdir matterjs && cd matterjs
  175. $ dpm init -A
  176. $ dpm install npm:matter-js
  177. # javascript keywords
  178. arguments else in super
  179. await enum instanceof switch
  180. break eval interface this
  181. case export let throw
  182. catch extends new true
  183. class false null try
  184. const finally package typeof
  185. continue for private var
  186. debugger function protected void
  187. default if public while
  188. delete implements return with
  189. do import static yield
  190. # math
  191. The Math class supplies the constants Math.E, Math.PI, Math.LN2, and Math.LN10.
  192. Some of the methods supplied by the Math class are:
  193. Math.abs(x) - Returns the absolute value of x
  194. Math.sign(x) - Returns the one of -1, 0, or 1 that has the same sign as x
  195. Math.trunc(x) - Returns the integer portion of x
  196. Math.round(x) - Returns the integer nearest to x
  197. Math.floor(x) - Returns the largest integer less than or equal to x
  198. Math.ceil(x) - Returns the smallest integer greater than or equal to x
  199. Math.max(x1,x2,...,xN) - Returns the largest of its arguments
  200. Math.min(x1,x2,...,xN) - Returns the smallest of its arguments
  201. Math.sqrt(x) - Returns the positive square root of x
  202. Math.cbrt(x) - Returns the cube root of x
  203. Math.random() - Returns a pseudo-random number r in the range 0 <= r < 1
  204. The Math class also supplies the standard logarithmic and trignometric functions exp,
  205. log, log10, log2, sin, cos, tan, asin, acos, atan, as well as the hyperbolic functions
  206. sinh, cosh, tanh, asinh, acosh, and atanh. All angles are in radians.