cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

              <!-- Add this to <head> -->
<link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap/dist/css/bootstrap.min.css"/>
<link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.css"/>

<script crossorigin src="https://unpkg.com/vue@2.5.17/dist/vue.min.js"></script>
<!-- Add this after vue.js -->
<script crossorigin src="//unpkg.com/babel-polyfill@latest/dist/polyfill.min.js"></script>
<script crossorigin src="//unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.js"></script>
<div id='app'>
  <h1>Post-Money SAFE Calculator</h1>
  <p>Add User Guide FIXME</p>
    <table class="table">
          <th>Purchase Amount</th>
          <th>Post-Money Target</th>
             <b-form-input step="100" v-model.number="founderShares" @input="computeModel()" type="number"></b-form-input> 
          <td>{{$r(founderShares / totalShares * 100)}}%</td>
        <tr v-for="i in investments">
          <td><b-form-input v-model="i.name" type="text"/></td>
          <td>{{$r(i.shares / totalShares * 100)}}%</td>
          <td><b-form-input step="10000" v-model.number="i.investment" @input="computeModel()" type="number"/></td>
          <td><b-form-input step="100000" v-model.number="i.postmoney" @input="computeModel()" type="number"/></td>
          <td><b-button variant="danger" @click="deleteInvestment(i)">-</b-button></td>
      <tfoot><tr><td>Totals</td><td></td><td>{{totalShares}}</td><td></td><td></td><td></td><td></td></tr> </tfoot>
    <b-button variant="primary" @click="addInvestment()">Add Investment</b-button>
    <b-button variant="secondary" @click="computeModel(); console.log(investments)">Recompute</b-button>
              #app {
  margin: 30px;

              function model(args) {
    var [shareBase, investments] = args
    var totalShares = shareBase;
    investments.map(function(inv) {
        var seriesAPrice = investments[0].price 
        var shares = Math.round(
           inv.investment/Math.min(inv.price, seriesAPrice));
        inv.shares = shares;
        totalShares += shares;
    // Compute new prices based on the new totalShares.
    investments.map(function(inv) {
        inv.price = inv.postmoney / totalShares
    return [shareBase, investments]

iterate = (f, n, args) => (n === 0)?args:iterate(f, n - 1, f(args))

new Vue({
  el: '#app',
  data: function() {
    return { 
      founderShares: 100000,
      investmentNr: 1,
      investments: [
        {name: "Series A", price: 1, investment: 2000000, postmoney: 6000000, shares: 1},
        {name: "Safe: Standard YC Deal", price: 1, investment: 150000, postmoney: 2000000, shares: 1},
        {name: "Safe B", price: 1, investment: 250000, postmoney: 3000000, shares: 1},
        {name: "Safe C", price: 1, investment: 250000, postmoney: 4000000, shares: 1},
        {name: "Safe D", price: 1, investment: 200000, postmoney: 8000000, shares: 1}]
  computed: {
    totalShares: function() {
      return this.investments.reduce((a, b) => a + b.shares, this.founderShares)
  methods: {
    addInvestment: function() {
      this.investments.push({name: "Safe " + this.investmentNr++, price: 1, investment: 150000, postmoney: 2000000, shares: 1});
    deleteInvestment: function(i) {
      this.investments = this.investments.filter(x => i !== x);
    $r: val => Math.round(val*100)/100,
    computeModel: function() {
      // Set price to something sane.
      this.investments.map(i => i.price = 1)
      iterate(model, 40, [this.founderShares, this.investments]);
  ready: function() { this.computeModel(); }

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................