nerdamer 1.1.9 → 1.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/gulpfile.js ADDED
@@ -0,0 +1,16 @@
1
+ var gulp = require('gulp');
2
+ var concat = require('gulp-concat');
3
+ var uglify = require('gulp-uglify');
4
+
5
+ var devFiles = ['./nerdamer.core.js','./Algebra.js', './Calculus.js', './Solve.js', './Extra.js'];
6
+
7
+ gulp.task('concat_all', function() {
8
+ return gulp.src(devFiles)
9
+ .pipe(concat('all.min.js'))
10
+ .pipe(uglify())
11
+ .pipe(gulp.dest('./'));
12
+ });
13
+
14
+ gulp.task('watch', function() {
15
+ gulp.watch(devFiles, gulp.series('concat_all'));
16
+ });
package/index.d.ts CHANGED
@@ -68,6 +68,12 @@ declare namespace nerdamer {
68
68
  */
69
69
  export function convertToLaTeX(expression: string): string
70
70
 
71
+ /**
72
+ * Attempts to import a LaTeX string.
73
+ * @param TeX The expression being converted.
74
+ */
75
+ export function convertFromLaTeX(TeX: string): Expression
76
+
71
77
  /**
72
78
  * Each time an expression is parsed nerdamer stores the result. Use this method to get back stored expressions.
73
79
  * @param asObject Pass in true to get expressions as numbered object with 1 as starting index
@@ -115,19 +121,19 @@ return _.multiply(sum, product)
115
121
  }
116
122
  //register the function with nerdamer
117
123
  nerdamer.register({
118
- name: 'myFunction',
119
- numargs: 2,
120
- visible: true,
121
- build: function(){ return f }
124
+ name: 'myFunction',
125
+ numargs: 2,
126
+ visible: true,
127
+ build: function(){ return f }
122
128
  })
123
129
 
124
130
  //create an alias for the diff function
125
131
  var core = nerdamer.getCore()
126
132
  nerdamer.register({
127
- name: 'D',
128
- visible: true,
129
- numargs: [1, 3],
130
- build: function(){ return core.Calculus.diff }
133
+ name: 'D',
134
+ visible: true,
135
+ numargs: [1, 3],
136
+ build: function(){ return core.Calculus.diff }
131
137
  })
132
138
  */
133
139
  export function register(f: ModuleFunction | ModuleFunction[]): typeof nerdamer
@@ -190,7 +196,7 @@ return _.multiply(sum, product)
190
196
  * Generates a JavaScript function given the expression. This is perfect for plotting and filtering user input. Plotting for the demo is accomplished using this. The order of the parameters is in alphabetical order by default but an argument array can be provided with the desired order.
191
197
  * @param args_array The argument array with the order in which they are preferred.
192
198
  */
193
- buildFunction(args_array: string[]): (...args: number[]) => number
199
+ buildFunction(args_array?: string[]): (...args: number[]) => number
194
200
 
195
201
  /**
196
202
  * Forces evaluation of the expression.
@@ -220,6 +226,11 @@ return _.multiply(sum, product)
220
226
  */
221
227
  toTeX(): string
222
228
 
229
+ /**
230
+ * Returns the value of the expression as a string or a number
231
+ */
232
+ valueOf(): string | number
233
+
223
234
  /**
224
235
  * Gets the list of reserved names. This is a list of names already in use by nerdamer excluding variable names. This is not a static list.
225
236
  * @param outputType Pass in the string 'decimals' to always get back numers as decimals. Pass in the string 'fractions' to always get back number as fractions. Defaults to decimals.
@@ -234,6 +245,132 @@ return _.multiply(sum, product)
234
245
  * eq.solveFor('x') // ?? TODO
235
246
  */
236
247
  solveFor(variable: string): Expression
248
+
249
+ /**
250
+ * Forces the expression to displayed with decimals
251
+ */
252
+ toDecimal(prec?: number): string
253
+
254
+ /**
255
+ * Checks to see if the expression's value equals a number. Compares the direct value returned.
256
+ * The function will not check for all possible cases. To avoid this call evaluate.
257
+ * @example
258
+ * nerdamer('sqrt(5)').isNumber()
259
+ * // false
260
+ * nerdamer('sqrt(5)').evaluate().isNumber()
261
+ * // true
262
+ */
263
+ isNumber(): boolean
264
+
265
+ /**
266
+ * Checks if a number evaluates to an imaginary number
267
+ * @example
268
+ * nerdamer('sqrt(-5)+8').isImaginary()
269
+ * // true
270
+ * nerdamer('sqrt(5)+8').isImaginary()
271
+ * // false
272
+ */
273
+ isImaginary(): boolean
274
+
275
+ /**
276
+ * Adds a value to an expression
277
+ * @example
278
+ * nerdamer('x').add(3)
279
+ */
280
+ add(symbol: number | string | Expression): Expression
281
+
282
+ /**
283
+ * Subtracts a value from an expression
284
+ * @example
285
+ * nerdamer('x').subtract(3)
286
+ */
287
+ subtract(symbol: number | string | Expression): Expression
288
+
289
+ /**
290
+ * Multiplies an expression by a value
291
+ * @example
292
+ * nerdamer('x').multiply(3)
293
+ */
294
+ multiply(symbol: number | string | Expression): Expression
295
+
296
+ /**
297
+ * Divides an expression by a valule
298
+ * @example
299
+ * nerdamer('9*x').divide(3)
300
+ */
301
+ divide(symbol: number | string | Expression): Expression
302
+
303
+ /**
304
+ * Raises an expression to a power
305
+ * @example
306
+ * nerdamer('x').pow(3)
307
+ */
308
+ pow(symbol: number | string | Expression): Expression
309
+
310
+ /**
311
+ * Checks if two values are equal
312
+ * @param value The value being tested
313
+ * @example
314
+ * nerdamer('sqrt(9)').eq(3)
315
+ * // true
316
+ * nerdamer('x').eq('y')
317
+ * // false
318
+ */
319
+ eq(value: number | string | Expression): boolean
320
+
321
+ /**
322
+ * Checks if a value is less than another
323
+ * @param value The value being tested
324
+ * @example
325
+ * nerdamer('sqrt(9)').lt(3)
326
+ * // false
327
+ * nerdamer('8').lt(100)
328
+ * // true
329
+ */
330
+ lt(value: number | string | Expression): boolean
331
+
332
+ /**
333
+ * Checks if a value is less than or equal to another
334
+ * @param value The value being tested
335
+ * @example
336
+ * nerdamer('sqrt(9)').lte(3)
337
+ * // true
338
+ * nerdamer('x').lte(100)
339
+ * // false
340
+ */
341
+ lte(value: number | string | Expression): boolean
342
+
343
+ /**
344
+ * Checks if a value is greater than another
345
+ * @param value The value being tested
346
+ * @example
347
+ * nerdamer('sqrt(9)').gt(3)
348
+ * // false
349
+ * nerdamer('800').gt(100)
350
+ * // true
351
+ */
352
+ gt(value: number | string | Expression): boolean
353
+
354
+ /**
355
+ * Checks if a value is greater than or equal to another
356
+ * @param value The value being tested
357
+ * @example
358
+ * nerdamer('sqrt(9)').gte(3)
359
+ * // true
360
+ * nerdamer('x').gte(100)
361
+ * // false
362
+ */
363
+ gte(value: number | string | Expression): boolean
364
+
365
+ /**
366
+ * Expands a function or expression.
367
+ * @example
368
+ * nerdamer('x*(x+1)').expand();
369
+ * // x+x^2
370
+ * nerdamer('(x+y)*(x-5)*x').expand();
371
+ * // -5*x*y-5*x^2+x^3+x^2*y
372
+ */
373
+ expand(): Expression
237
374
  }
238
375
 
239
376
  ////////// CALCULUS
@@ -246,9 +383,9 @@ return _.multiply(sum, product)
246
383
  * @param upper Ending index.
247
384
  */
248
385
  export function sum(expression: ExpressionParam,
249
- index: string,
250
- lower: ExpressionParam,
251
- upper: ExpressionParam): Expression
386
+ index: string,
387
+ lower: ExpressionParam,
388
+ upper: ExpressionParam): Expression
252
389
 
253
390
  /**
254
391
  *
@@ -290,4 +427,4 @@ return _.multiply(sum, product)
290
427
  * @param expression
291
428
  */
292
429
  export function factor(expression: ExpressionParam): Expression
293
- }
430
+ }